On 21 May 2012 11:08, Pauli Nieminen <[email protected]> wrote:
> piglit-dispatch-init.c needs some piglit util functions but it may not > include piglit-dispatch.h to keep direct linking to egl and glX possible > if we aren't using waffle. > Can you go into more detail about what would go wrong if we had piglit-dispatch-init.c include piglit-dispatch.h? I have been thinking of piglit-dispatch.h as the public interface to the piglit-dispatch mechanism, and since piglit-dispatch-init.c's role is to initialize the piglit-dispatch mechanism, it seems sensible for it to include piglit-dispatch.h directly rather than move a bunch of piglit-dispatch stuff into a file whose name doesn't sound related to piglit-dispatch. If there's no way to avoid splitting out these files, maybe we could consider renaming piglit-util-core.h to something like piglit-dispatch-minimal.h or piglit-dispatch-core.h, to clarify that its purpose is to declare a core subset of the piglit-dispatch functionality, not a core subset of piglit-util functionality. > > The core header is minimum set of interfaces required by dispatch init. > > Signed-off-by: Pauli Nieminen <[email protected]> > --- > tests/util/piglit-dispatch-init.c | 4 +- > tests/util/piglit-dispatch.h | 49 +------------------- > tests/util/piglit-util-core.h | 92 > +++++++++++++++++++++++++++++++++++++ > tests/util/piglit-util.h | 33 +------------- > 4 files changed, 98 insertions(+), 80 deletions(-) > create mode 100644 tests/util/piglit-util-core.h > > diff --git a/tests/util/piglit-dispatch-init.c > b/tests/util/piglit-dispatch-init.c > index 2a4bcf6..dbe9842 100644 > --- a/tests/util/piglit-dispatch-init.c > +++ b/tests/util/piglit-dispatch-init.c > @@ -22,7 +22,9 @@ > > #define _GNU_SOURCE > #include <dlfcn.h> > -#include "piglit-util.h" > +#include "piglit-util-core.h" > +#include <stdio.h> > +#include <string.h> > > #if defined(_WIN32) > > diff --git a/tests/util/piglit-dispatch.h b/tests/util/piglit-dispatch.h > index 002b8c0..adc01e4 100644 > --- a/tests/util/piglit-dispatch.h > +++ b/tests/util/piglit-dispatch.h > @@ -56,36 +56,12 @@ > #include <stdint.h> > #include <stddef.h> > > +#include "piglit-util-core.h" > + > #ifdef __cplusplus > extern "C" { > #endif > > -#ifndef _WIN32 > - > -/* APIENTRY and GLAPIENTRY are not used on Linux or Mac. */ > -#ifndef APIENTRY > -#define APIENTRY > -#endif > -#ifndef GLAPIENTRY > -#define GLAPIENTRY > -#endif > - > -#else > - > -#ifndef APIENTRY > -#define APIENTRY __stdcall > -#endif > - > -#ifndef GLAPIENTRY > -#define GLAPIENTRY APIENTRY > -#endif > - > -#ifndef GLAPI > -#define GLAPI extern > -#endif > - > -#endif > - > typedef unsigned int GLenum; > typedef unsigned int GLbitfield; > typedef unsigned int GLuint; > @@ -131,27 +107,6 @@ typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint > id,GLenum category,GLenum severit > > typedef void (APIENTRY *piglit_dispatch_function_ptr)(void); > > -typedef piglit_dispatch_function_ptr > (*piglit_get_core_proc_address_function_ptr)(const char *, int); > - > -typedef piglit_dispatch_function_ptr > (*piglit_get_ext_proc_address_function_ptr)(const char *); > - > -typedef piglit_dispatch_function_ptr (*piglit_dispatch_resolver_ptr)(); > - > -typedef void (*piglit_error_function_ptr)(const char *); > - > -typedef enum { > - PIGLIT_DISPATCH_GL, > - PIGLIT_DISPATCH_GL_FWD, > - PIGLIT_DISPATCH_ES1, > - PIGLIT_DISPATCH_ES2 > -} piglit_dispatch_api; > - > -void piglit_dispatch_init(piglit_dispatch_api api, > - piglit_get_core_proc_address_function_ptr > get_core_proc, > - piglit_get_ext_proc_address_function_ptr > get_ext_proc, > - piglit_error_function_ptr unsupported_proc, > - piglit_error_function_ptr failure_proc); > - > piglit_dispatch_function_ptr > piglit_dispatch_resolve_function(const char *name); > > diff --git a/tests/util/piglit-util-core.h b/tests/util/piglit-util-core.h > new file mode 100644 > index 0000000..46dd1c8 > --- /dev/null > +++ b/tests/util/piglit-util-core.h > @@ -0,0 +1,92 @@ > + > +#pragma once > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +#if defined(_WIN32) > +#include <windows.h> > +#endif > + > +#if defined(_MSC_VER) > +typedef signed char int8_t; > +typedef __int16 int16_t; > +typedef __int32 int32_t; > +typedef __int64 int64_t; > +typedef unsigned __int8 uint8_t; > +typedef unsigned __int16 uint16_t; > +typedef unsigned __int32 uint32_t; > +typedef unsigned __int64 uint64_t; > +#ifndef __cplusplus > +#define bool BOOL > +#define true 1 > +#define false 0 > +#endif > +#define log2(x) (log(x) / log(2)) > +#else > +#include <stdint.h> > +#include <stdbool.h> > +#endif > + > +enum piglit_result { > + PIGLIT_PASS, > + PIGLIT_FAIL, > + PIGLIT_SKIP, > + PIGLIT_WARN > +}; > + > +void piglit_report_result(enum piglit_result result); > + > +#ifndef _WIN32 > + > +/* APIENTRY and GLAPIENTRY are not used on Linux or Mac. */ > +#ifndef APIENTRY > +#define APIENTRY > +#endif > +#ifndef GLAPIENTRY > +#define GLAPIENTRY > +#endif > + > +#else > + > +#ifndef APIENTRY > +#define APIENTRY __stdcall > +#endif > + > +#ifndef GLAPIENTRY > +#define GLAPIENTRY APIENTRY > +#endif > + > +#ifndef GLAPI > +#define GLAPI extern > +#endif > + > +#endif > + > +typedef enum { > + PIGLIT_DISPATCH_GL, > + PIGLIT_DISPATCH_GL_FWD, > + PIGLIT_DISPATCH_ES1, > + PIGLIT_DISPATCH_ES2 > +} piglit_dispatch_api; > + > +typedef void (APIENTRY *piglit_dispatch_function_ptr)(void); > + > +typedef piglit_dispatch_function_ptr > (*piglit_get_core_proc_address_function_ptr)(const char *, int); > + > +typedef piglit_dispatch_function_ptr > (*piglit_get_ext_proc_address_function_ptr)(const char *); > + > +typedef piglit_dispatch_function_ptr (*piglit_dispatch_resolver_ptr)(); > + > +typedef void (*piglit_error_function_ptr)(const char *); > + > +void piglit_dispatch_init(piglit_dispatch_api api, > + piglit_get_core_proc_address_function_ptr > get_core_proc, > + piglit_get_ext_proc_address_function_ptr > get_ext_proc, > + piglit_error_function_ptr unsupported_proc, > + piglit_error_function_ptr failure_proc); > + > +#ifdef __cplusplus > +} > +#endif > diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h > index 51c3220..6db440a 100755 > --- a/tests/util/piglit-util.h > +++ b/tests/util/piglit-util.h > @@ -30,30 +30,7 @@ extern "C" { > #endif > > #include "config.h" > - > -#if defined(_WIN32) > -#include <windows.h> > -#endif > - > -#if defined(_MSC_VER) > -typedef signed char int8_t; > -typedef __int16 int16_t; > -typedef __int32 int32_t; > -typedef __int64 int64_t; > -typedef unsigned __int8 uint8_t; > -typedef unsigned __int16 uint16_t; > -typedef unsigned __int32 uint32_t; > -typedef unsigned __int64 uint64_t; > -#ifndef __cplusplus > -#define bool BOOL > -#define true 1 > -#define false 0 > -#endif > -#define log2(x) (log(x) / log(2)) > -#else > -#include <stdint.h> > -#include <stdbool.h> > -#endif > +#include "piglit-util-core.h" > > #include <assert.h> > #include <string.h> > @@ -108,13 +85,6 @@ int asprintf(char **strp, const char *fmt, ...) > > #define piglit_get_proc_address(x) piglit_dispatch_resolve_function(x) > > -enum piglit_result { > - PIGLIT_PASS, > - PIGLIT_FAIL, > - PIGLIT_SKIP, > - PIGLIT_WARN > -}; > - > #include "piglit-framework.h" > #include "piglit-shader.h" > #include "piglit-transform-feedback.h" > @@ -203,7 +173,6 @@ void piglit_reset_gl_error(void); > > int FindLine(const char *program, int position); > void piglit_merge_result(enum piglit_result *all, enum piglit_result > subtest); > -void piglit_report_result(enum piglit_result result); > void piglit_require_gl_version(int required_version_times_10); > void piglit_require_extension(const char *name); > void piglit_require_not_extension(const char *name); > -- > 1.7.5.4 > > _______________________________________________ > Piglit mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/piglit >
_______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
