aboutsummaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorNorbert Nopper <Norbert.Nopper@freescale.com>2015-02-06 20:53:06 +0100
committerNorbert Nopper <Norbert.Nopper@freescale.com>2015-02-06 20:53:06 +0100
commita51adace2a7b9beae892d47483c98e581bfe8b73 (patch)
treea3dd4f224bc361f782671213eaf12f0e00501a22 /loader
parent55224df6187bcbbd70a0424b95e3d446111bd8b4 (diff)
parent3e32b4dfe595e4d00aa9b2cabc1e9b9a78f1649c (diff)
downloadusermoji-a51adace2a7b9beae892d47483c98e581bfe8b73.tar.xz
Merge pull request #1 from KhronosGroup/master
Update from head fork.
Diffstat (limited to 'loader')
-rw-r--r--loader/CMakeLists.txt11
-rw-r--r--loader/loader.c87
-rw-r--r--loader/loader_platform.h54
3 files changed, 78 insertions, 74 deletions
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index 13a4b5b7..2d2febfe 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -11,13 +11,18 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES")
if (WIN32)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS")
+
add_library(XGL SHARED loader.c dirent_on_windows.c dispatch.c table_ops.h)
+ set_target_properties(XGL PROPERTIES SOVERSION 0)
+ target_link_libraries(XGL)
endif()
if (NOT WIN32)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES")
+
add_library(XGL SHARED loader.c dispatch.c table_ops.h)
+ set_target_properties(XGL PROPERTIES SOVERSION 0)
+ target_link_libraries(XGL -ldl -lpthread)
endif()
-set_target_properties(XGL PROPERTIES SOVERSION 0)
-target_link_libraries(XGL -ldl -lpthread)
diff --git a/loader/loader.c b/loader/loader.c
index c4cdce02..2ea37e71 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -338,49 +338,6 @@ static void loader_scanned_icd_add(const char *filename)
loader.scanned_icd_list = new_node;
}
-#if defined(WIN32)
-
-#define PATH_SEPERATOR ';'
-#define DIRECTORY_SYMBOL "\\"
-#ifndef DEFAULT_XGL_DRIVERS_PATH
-// TODO: Is this a good default location?
-// Need to search for both 32bit and 64bit ICDs
-#define DEFAULT_XGL_DRIVERS_PATH "C:\\Windows\\System32"
-// TODO/TBD: Is this an appropriate prefix for Windows?
-#define XGL_DRIVER_LIBRARY_PREFIX "XGL_"
-#define XGL_DRIVER_LIBRARY_PREFIX_LEN 4
-// TODO/TBD: Is this an appropriate suffix for Windows?
-#define XGL_LAYER_LIBRARY_PREFIX "XGLLayer"
-#define XGL_LAYER_LIBRARY_PREFIX_LEN 8
-#define XGL_LIBRARY_SUFFIX ".dll"
-#define XGL_LIBRARY_SUFFIX_LEN 4
-#endif // DEFAULT_XGL_DRIVERS_PATH
-#ifndef DEFAULT_XGL_LAYERS_PATH
-// TODO: Is this a good default location?
-#define DEFAULT_XGL_LAYERS_PATH "C:\\Windows\\System32"
-#endif // DEFAULT_XGL_LAYERS_PATH
-
-#else // WIN32
-
-#define PATH_SEPERATOR ':'
-#define DIRECTORY_SYMBOL "/"
-#ifndef DEFAULT_XGL_DRIVERS_PATH
-// TODO: Is this a good default location?
-// Need to search for both 32bit and 64bit ICDs
-#define DEFAULT_XGL_DRIVERS_PATH "/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl"
-#define XGL_DRIVER_LIBRARY_PREFIX "libXGL_"
-#define XGL_DRIVER_LIBRARY_PREFIX_LEN 7
-#define XGL_LAYER_LIBRARY_PREFIX "libXGLLayer"
-#define XGL_LAYER_LIBRARY_PREFIX_LEN 11
-#define XGL_LIBRARY_SUFFIX ".so"
-#define XGL_LIBRARY_SUFFIX_LEN 3
-#endif // DEFAULT_XGL_DRIVERS_PATH
-#ifndef DEFAULT_XGL_LAYERS_PATH
-// TODO: Are these good default locations?
-#define DEFAULT_XGL_LAYERS_PATH ".:/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl"
-#endif
-
-#endif // WIN32
/**
* Try to \c loader_icd_scan XGL driver(s).
@@ -399,7 +356,7 @@ static void loader_icd_scan(void)
struct dirent *dent;
char icd_library[1024];
char path[1024];
- int len;
+ uint32_t len;
libPaths = NULL;
#if !defined(WIN32)
@@ -416,11 +373,11 @@ static void loader_icd_scan(void)
for (p = libPaths; *p; p = next) {
next = strchr(p, PATH_SEPERATOR);
if (next == NULL) {
- len = strlen(p);
+ len = (uint32_t) strlen(p);
next = p + len;
}
else {
- len = next - p;
+ len = (uint32_t) (next - p);
sprintf(path, "%.*s", (len > sizeof(path) - 1) ? (int) sizeof(path) - 1 : len, p);
p = path;
next++;
@@ -438,7 +395,7 @@ static void loader_icd_scan(void)
if (!strncmp(dent->d_name,
XGL_DRIVER_LIBRARY_PREFIX,
XGL_DRIVER_LIBRARY_PREFIX_LEN)) {
- int nlen = strlen(dent->d_name);
+ uint32_t nlen = (uint32_t) strlen(dent->d_name);
const char *suf = dent->d_name + nlen - XGL_LIBRARY_SUFFIX_LEN;
if ((nlen > XGL_LIBRARY_SUFFIX_LEN) &&
!strncmp(suf,
@@ -465,13 +422,13 @@ static void layer_lib_scan_path(const char * libInPaths)
char *libPaths;
DIR *curdir;
struct dirent *dent;
- int len, i;
+ uint32_t len, i;
char temp_str[1024];
len = 0;
loader.layer_dirs = NULL;
if (libInPaths){
- len = strlen(libInPaths);
+ len = (uint32_t) strlen(libInPaths);
p = libInPaths;
}
else {
@@ -480,14 +437,14 @@ static void layer_lib_scan_path(const char * libInPaths)
#endif // WIN32
p = getenv("LIBXGL_LAYERS_PATH");
if (p != NULL)
- len = strlen(p);
+ len = (uint32_t) strlen(p);
#if !defined(WIN32)
}
#endif // WIN32
}
if (len == 0) {
- len = strlen(DEFAULT_XGL_LAYERS_PATH);
+ len = (uint32_t) strlen(DEFAULT_XGL_LAYERS_PATH);
p = DEFAULT_XGL_LAYERS_PATH;
}
@@ -514,11 +471,11 @@ static void layer_lib_scan_path(const char * libInPaths)
for (p = libPaths; *p; p = next) {
next = strchr(p, PATH_SEPERATOR);
if (next == NULL) {
- len = strlen(p);
+ len = (uint32_t) strlen(p);
next = p + len;
}
else {
- len = next - p;
+ len = (uint32_t) (next - p);
*(char *) next = '\0';
next++;
}
@@ -533,7 +490,7 @@ static void layer_lib_scan_path(const char * libInPaths)
if (!strncmp(dent->d_name,
XGL_LAYER_LIBRARY_PREFIX,
XGL_LAYER_LIBRARY_PREFIX_LEN)) {
- int nlen = strlen(dent->d_name);
+ uint32_t nlen = (uint32_t) strlen(dent->d_name);
const char *suf = dent->d_name + nlen - XGL_LIBRARY_SUFFIX_LEN;
if ((nlen > XGL_LIBRARY_SUFFIX_LEN) &&
!strncmp(suf,
@@ -569,7 +526,7 @@ static void layer_lib_scan_path(const char * libInPaths)
loader.layer_scanned = true;
}
-static void layer_lib_scan()
+static void layer_lib_scan(void)
{
layer_lib_scan_path(NULL);
}
@@ -704,11 +661,11 @@ static uint32_t loader_get_layer_env(struct loader_icd *icd, uint32_t gpu_index,
const char *lib_name = NULL;
next = strchr(p, PATH_SEPERATOR);
if (next == NULL) {
- len = strlen(p);
+ len = (uint32_t) strlen(p);
next = p + len;
}
else {
- len = next - p;
+ len = (uint32_t) (next - p);
*(char *) next = '\0';
next++;
}
@@ -718,7 +675,7 @@ static uint32_t loader_get_layer_env(struct loader_icd *icd, uint32_t gpu_index,
continue;
}
- len = strlen(name);
+ len = (uint32_t) strlen(name);
pLayerNames[count].layer_name = malloc(len + 1);
if (!pLayerNames[count].layer_name) {
free(pOrig);
@@ -757,7 +714,7 @@ static uint32_t loader_get_layer_libs(struct loader_icd *icd, uint32_t gpu_index
name = *(pCi->ppActiveLayerNames + i);
if (!find_layer_name(icd, gpu_index, name, &lib_name))
return loader_get_layer_env(icd, gpu_index, layerNames);
- len = strlen(name);
+ len = (uint32_t) strlen(name);
layerNames[i].layer_name = malloc(len + 1);
if (!layerNames[i].layer_name)
return i;
@@ -1002,7 +959,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus(
icd->gpu_count = n;
icd->loader_dispatch = (XGL_LAYER_DISPATCH_TABLE *) malloc(n *
sizeof(XGL_LAYER_DISPATCH_TABLE));
- for (int i = 0; i < n; i++) {
+ for (unsigned int i = 0; i < n; i++) {
(wrapped_gpus + i)->baseObject = gpus[i];
(wrapped_gpus + i)->pGPA = get_proc_addr;
(wrapped_gpus + i)->nextObject = gpus[i];
@@ -1063,7 +1020,7 @@ LOADER_EXPORT void * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char * pN
LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved)
{
uint32_t gpu_index;
- uint32_t count = 0;
+ size_t count = 0;
char *lib_name;
struct loader_icd *icd = loader_get_icd((const XGL_BASE_LAYER_OBJECT *) gpu, &gpu_index);
loader_platform_dl_handle handle;
@@ -1092,7 +1049,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t
loader_platform_close_library(handle);
lib_name = basename(lib_name);
pEnd = strrchr(lib_name, '.');
- siz = pEnd - lib_name - strlen(XGL_LAYER_LIBRARY_PREFIX) + 1;
+ siz = (int) (pEnd - lib_name - strlen(XGL_LAYER_LIBRARY_PREFIX) + 1);
if (pEnd == NULL || siz <= 0)
continue;
cpyStr = malloc(siz);
@@ -1103,7 +1060,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t
strncpy(cpyStr, lib_name + strlen(XGL_LAYER_LIBRARY_PREFIX), siz);
cpyStr[siz - 1] = '\0';
if (siz > maxStringSize)
- siz = maxStringSize;
+ siz = (int) maxStringSize;
strncpy((char *) (pOutLayers[count]), cpyStr, siz);
pOutLayers[count][siz - 1] = '\0';
count++;
@@ -1113,14 +1070,14 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t
size_t cnt;
uint32_t n;
XGL_RESULT res;
- n = (maxStringSize < 256) ? maxStringSize : 256;
+ n = (uint32_t) ((maxStringSize < 256) ? maxStringSize : 256);
res = fpEnumerateLayers(NULL, 16, n, &cnt, layers, (char *) icd->gpus + gpu_index);
loader_platform_close_library(handle);
if (res != XGL_SUCCESS)
continue;
if (cnt + count > maxLayerCount)
cnt = maxLayerCount - count;
- for (unsigned int i = count; i < cnt + count; i++) {
+ for (uint32_t i = (uint32_t) count; i < cnt + count; i++) {
strncpy((char *) (pOutLayers[i]), (char *) layers[i - count], n);
if (n > 0)
pOutLayers[i - count][n - 1] = '\0';
diff --git a/loader/loader_platform.h b/loader/loader_platform.h
index a9cd4df1..e567700b 100644
--- a/loader/loader_platform.h
+++ b/loader/loader_platform.h
@@ -42,6 +42,25 @@
#include <pthread.h>
#include <assert.h>
+// XGL Library Filenames, Paths, etc.:
+#define PATH_SEPERATOR ':'
+#define DIRECTORY_SYMBOL "/"
+#ifndef DEFAULT_XGL_DRIVERS_PATH
+// TODO: Is this a good default location?
+// Need to search for both 32bit and 64bit ICDs
+#define DEFAULT_XGL_DRIVERS_PATH "/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl"
+#define XGL_DRIVER_LIBRARY_PREFIX "libXGL_"
+#define XGL_DRIVER_LIBRARY_PREFIX_LEN 7
+#define XGL_LAYER_LIBRARY_PREFIX "libXGLLayer"
+#define XGL_LAYER_LIBRARY_PREFIX_LEN 11
+#define XGL_LIBRARY_SUFFIX ".so"
+#define XGL_LIBRARY_SUFFIX_LEN 3
+#endif // DEFAULT_XGL_DRIVERS_PATH
+#ifndef DEFAULT_XGL_LAYERS_PATH
+// TODO: Are these good default locations?
+#define DEFAULT_XGL_LAYERS_PATH ".:/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl"
+#endif
+
// C99:
#define STATIC_INLINE static inline
@@ -124,10 +143,32 @@ static inline void loader_platform_thread_delete_mutex(loader_platform_thread_mu
using namespace std;
#endif // __cplusplus
+// XGL Library Filenames, Paths, etc.:
+#define PATH_SEPERATOR ';'
+#define DIRECTORY_SYMBOL "\\"
+#ifndef DEFAULT_XGL_DRIVERS_PATH
+// TODO: Is this a good default location?
+// Need to search for both 32bit and 64bit ICDs
+#define DEFAULT_XGL_DRIVERS_PATH "C:\\Windows\\System32"
+// TODO/TBD: Is this an appropriate prefix for Windows?
+#define XGL_DRIVER_LIBRARY_PREFIX "XGL_"
+#define XGL_DRIVER_LIBRARY_PREFIX_LEN 4
+// TODO/TBD: Is this an appropriate suffix for Windows?
+#define XGL_LAYER_LIBRARY_PREFIX "XGLLayer"
+#define XGL_LAYER_LIBRARY_PREFIX_LEN 8
+#define XGL_LIBRARY_SUFFIX ".dll"
+#define XGL_LIBRARY_SUFFIX_LEN 4
+#endif // DEFAULT_XGL_DRIVERS_PATH
+#ifndef DEFAULT_XGL_LAYERS_PATH
+// TODO: Is this a good default location?
+#define DEFAULT_XGL_LAYERS_PATH "C:\\Windows\\System32"
+#endif // DEFAULT_XGL_LAYERS_PATH
+
// C99:
// Microsoft didn't implement C99 in Visual Studio; but started adding it with
// VS2013. However, VS2013 still didn't have snprintf(). The following is a
-// work-around.
+// work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the
+// "CMakeLists.txt" file).
#define snprintf _snprintf
#define STATIC_INLINE static
// Microsoft also doesn't have basename(). Paths are different on Windows, and
@@ -139,20 +180,21 @@ static char *basename(char *pathname)
{
char *current, *next;
-#define DIRECTORY_SYMBOL '\\'
-
// TODO/TBD: Do we need to deal with the Windows's ":" character?
+#define DIRECTORY_SYMBOL_CHAR '\\'
for (current = pathname; *current != '\0'; current = next) {
- next = strchr(current, DIRECTORY_SYMBOL);
+ next = strchr(current, DIRECTORY_SYMBOL_CHAR);
if (next == NULL) {
- // No more DIRECTORY_SYMBOL's so return p:
+ // No more DIRECTORY_SYMBOL_CHAR's so return p:
return current;
} else {
- // Point one character past the DIRECTORY_SYMBOL:
+ // Point one character past the DIRECTORY_SYMBOL_CHAR:
next++;
}
}
+ // We shouldn't get to here, but this makes the compiler happy:
+ return current;
}
// Dynamic Loading: