/* * This file was automatically generated by create-native-map from TestMap.dll. * * DO NOT MODIFY. */ #ifdef HAVE_CONFIG_H #include #endif /* ndef HAVE_CONFIG_H */ #include #include /* * Implementation Macros */ #ifndef FOO #define FOO "foo" #endif /* ndef FOO */ /* * Implementation Includes */ #ifdef HAVE_UNISTD_H #include #endif /* ndef HAVE_UNISTD_H */ #include #include "test.h" #include "test.h" #include /* errno, EOVERFLOW */ #include /* g* types, g_assert_not_reached() */ #if defined (G_MININT8) #define CNM_MININT8 G_MININT8 #else #define CNM_MININT8 (-128) #endif #if defined (G_MAXINT8) #define CNM_MAXINT8 G_MAXINT8 #else #define CNM_MAXINT8 (127) #endif #if defined (G_MAXUINT8) #define CNM_MAXUINT8 G_MAXUINT8 #else #define CNM_MAXUINT8 (255) #endif #if defined (G_MININT16) #define CNM_MININT16 G_MININT16 #else #define CNM_MININT16 (-32768) #endif #if defined (G_MAXINT16) #define CNM_MAXINT16 G_MAXINT16 #else #define CNM_MAXINT16 (32767) #endif #if defined (G_MAXUINT16) #define CNM_MAXUINT16 G_MAXUINT16 #else #define CNM_MAXUINT16 (65535) #endif #if defined (G_MININT32) #define CNM_MININT32 G_MININT32 #else #define CNM_MININT32 (-2147483648) #endif #if defined (G_MAXINT32) #define CNM_MAXINT32 G_MAXINT32 #else #define CNM_MAXINT32 (2147483647) #endif #if defined (G_MAXUINT32) #define CNM_MAXUINT32 G_MAXUINT32 #else #define CNM_MAXUINT32 (4294967295U) #endif #if defined (G_MININT64) #define CNM_MININT64 G_MININT64 #else #define CNM_MININT64 (-9223372036854775808LL) #endif #if defined (G_MAXINT64) #define CNM_MAXINT64 G_MAXINT64 #else #define CNM_MAXINT64 (9223372036854775807LL) #endif #if defined (G_MAXUINT64) #define CNM_MAXUINT64 G_MAXUINT64 #else #define CNM_MAXUINT64 (18446744073709551615ULL) #endif /* returns TRUE if @type is an unsigned type */ #define _cnm_integral_type_is_unsigned(type) \ (sizeof(type) == sizeof(gint8) \ ? (((type)-1) > CNM_MAXINT8) \ : sizeof(type) == sizeof(gint16) \ ? (((type)-1) > CNM_MAXINT16) \ : sizeof(type) == sizeof(gint32) \ ? (((type)-1) > CNM_MAXINT32) \ : sizeof(type) == sizeof(gint64) \ ? (((type)-1) > CNM_MAXINT64) \ : (g_assert_not_reached (), 0)) /* returns the minimum value of @type as a gint64 */ #define _cnm_integral_type_min(type) \ (_cnm_integral_type_is_unsigned (type) \ ? 0 \ : sizeof(type) == sizeof(gint8) \ ? CNM_MININT8 \ : sizeof(type) == sizeof(gint16) \ ? CNM_MININT16 \ : sizeof(type) == sizeof(gint32) \ ? CNM_MININT32 \ : sizeof(type) == sizeof(gint64) \ ? CNM_MININT64 \ : (g_assert_not_reached (), 0)) /* returns the maximum value of @type as a guint64 */ #define _cnm_integral_type_max(type) \ (_cnm_integral_type_is_unsigned (type) \ ? sizeof(type) == sizeof(gint8) \ ? CNM_MAXUINT8 \ : sizeof(type) == sizeof(gint16) \ ? CNM_MAXUINT16 \ : sizeof(type) == sizeof(gint32) \ ? CNM_MAXUINT32 \ : sizeof(type) == sizeof(gint64) \ ? CNM_MAXUINT64 \ : (g_assert_not_reached (), 0) \ : sizeof(type) == sizeof(gint8) \ ? CNM_MAXINT8 \ : sizeof(type) == sizeof(gint16) \ ? CNM_MAXINT16 \ : sizeof(type) == sizeof(gint32) \ ? CNM_MAXINT32 \ : sizeof(type) == sizeof(gint64) \ ? CNM_MAXINT64 \ : (g_assert_not_reached (), 0)) #ifdef _CNM_DUMP #define _cnm_dump(to_t,from) \ printf ("# %s -> %s: uns=%i; min=%llx; max=%llx; value=%llx; lt=%i; l0=%i; gt=%i; e=%i\n", \ #from, #to_t, \ (int) _cnm_integral_type_is_unsigned (to_t), \ (gint64) (_cnm_integral_type_min (to_t)), \ (gint64) (_cnm_integral_type_max (to_t)), \ (gint64) (from), \ (((gint64) _cnm_integral_type_min (to_t)) <= (gint64) from), \ (from < 0), \ (((guint64) from) <= (guint64) _cnm_integral_type_max (to_t)), \ !((int) _cnm_integral_type_is_unsigned (to_t) \ ? ((0 <= from) && \ ((guint64) from <= (guint64) _cnm_integral_type_max (to_t))) \ : ((gint64) _cnm_integral_type_min(to_t) <= (gint64) from && \ (guint64) from <= (guint64) _cnm_integral_type_max (to_t))) \ ) #else /* ndef _CNM_DUMP */ #define _cnm_dump(to_t, from) do {} while (0) #endif /* def _CNM_DUMP */ #ifdef DEBUG #define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \ int uns = _cnm_integral_type_is_unsigned (to_t); \ gint64 min = (gint64) _cnm_integral_type_min (to_t); \ guint64 max = (guint64) _cnm_integral_type_max (to_t); \ gint64 sf = (gint64) from; \ guint64 uf = (guint64) from; \ if (!(uns ? ((0 <= from) && (uf <= max)) \ : (min <= sf && (from < 0 || uf <= max)))) { \ _cnm_dump(to_t, from); \ errno = EOVERFLOW; \ return (val); \ } \ } G_STMT_END #else /* !def DEBUG */ /* don't do any overflow checking */ #define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \ } G_STMT_END #endif /* def DEBUG */ int MakeMap_Test_FromFlagsEnum (int x, int *r) { *r = 0; if ((x & MakeMap_Test_FlagsEnum_A) == MakeMap_Test_FlagsEnum_A) #ifdef A *r |= A; #else /* def A */ {errno = EINVAL; return -1;} #endif /* ndef A */ if ((x & MakeMap_Test_FlagsEnum_All) == MakeMap_Test_FlagsEnum_All) #ifdef All *r |= All; #else /* def All */ {/* Ignoring MakeMap_Test_FlagsEnum_All, as it is constructed from other values */} #endif /* ndef All */ if ((x & MakeMap_Test_FlagsEnum_B) == MakeMap_Test_FlagsEnum_B) #ifdef B *r |= B; #else /* def B */ {errno = EINVAL; return -1;} #endif /* ndef B */ if ((x & MakeMap_Test_FlagsEnum_C) == MakeMap_Test_FlagsEnum_C) #ifdef C *r |= C; #else /* def C */ {errno = EINVAL; return -1;} #endif /* ndef C */ if ((x & MakeMap_Test_FlagsEnum_D) == MakeMap_Test_FlagsEnum_D) #ifdef D *r |= D; #else /* def D */ {errno = EINVAL; return -1;} #endif /* ndef D */ if ((x & MakeMap_Test_FlagsEnum_None) == MakeMap_Test_FlagsEnum_None) #ifdef None *r |= None; #else /* def None */ {errno = EINVAL; return -1;} #endif /* ndef None */ if ((x & MakeMap_Test_FlagsEnum_S_IFMT) == MakeMap_Test_FlagsEnum_S_IFBLK) #ifdef S_IFBLK *r |= S_IFBLK; #else /* def S_IFBLK */ {errno = EINVAL; return -1;} #endif /* ndef S_IFBLK */ if ((x & MakeMap_Test_FlagsEnum_S_IFMT) == MakeMap_Test_FlagsEnum_S_IFCHR) #ifdef S_IFCHR *r |= S_IFCHR; #else /* def S_IFCHR */ {errno = EINVAL; return -1;} #endif /* ndef S_IFCHR */ if ((x & MakeMap_Test_FlagsEnum_S_IFMT) == MakeMap_Test_FlagsEnum_S_IFDIR) #ifdef S_IFDIR *r |= S_IFDIR; #else /* def S_IFDIR */ {errno = EINVAL; return -1;} #endif /* ndef S_IFDIR */ if ((x & MakeMap_Test_FlagsEnum_S_IFMT) == MakeMap_Test_FlagsEnum_S_IFIFO) #ifdef S_IFIFO *r |= S_IFIFO; #else /* def S_IFIFO */ {errno = EINVAL; return -1;} #endif /* ndef S_IFIFO */ if ((x & MakeMap_Test_FlagsEnum_S_IFMT) == MakeMap_Test_FlagsEnum_S_IFLNK) #ifdef S_IFLNK *r |= S_IFLNK; #else /* def S_IFLNK */ {errno = EINVAL; return -1;} #endif /* ndef S_IFLNK */ if ((x & MakeMap_Test_FlagsEnum_S_IFMT) == MakeMap_Test_FlagsEnum_S_IFMT) #ifdef S_IFMT *r |= S_IFMT; #else /* def S_IFMT */ {/* Ignoring MakeMap_Test_FlagsEnum_S_IFMT, as it is constructed from other values */} #endif /* ndef S_IFMT */ if ((x & MakeMap_Test_FlagsEnum_S_IFMT) == MakeMap_Test_FlagsEnum_S_IFREG) #ifdef S_IFREG *r |= S_IFREG; #else /* def S_IFREG */ {errno = EINVAL; return -1;} #endif /* ndef S_IFREG */ if ((x & MakeMap_Test_FlagsEnum_S_IFMT) == MakeMap_Test_FlagsEnum_S_IFSOCK) #ifdef S_IFSOCK *r |= S_IFSOCK; #else /* def S_IFSOCK */ {errno = EINVAL; return -1;} #endif /* ndef S_IFSOCK */ if (x == 0) return 0; return 0; } int MakeMap_Test_ToFlagsEnum (int x, int *r) { *r = 0; if (x == 0) return 0; #ifdef A if ((x & A) == A) *r |= MakeMap_Test_FlagsEnum_A; #endif /* ndef A */ #ifdef All if ((x & All) == All) *r |= MakeMap_Test_FlagsEnum_All; #endif /* ndef All */ #ifdef B if ((x & B) == B) *r |= MakeMap_Test_FlagsEnum_B; #endif /* ndef B */ #ifdef C if ((x & C) == C) *r |= MakeMap_Test_FlagsEnum_C; #endif /* ndef C */ #ifdef D if ((x & D) == D) *r |= MakeMap_Test_FlagsEnum_D; #endif /* ndef D */ #ifdef None if ((x & None) == None) *r |= MakeMap_Test_FlagsEnum_None; #endif /* ndef None */ #ifdef S_IFBLK if ((x & S_IFMT) == S_IFBLK) *r |= MakeMap_Test_FlagsEnum_S_IFBLK; #endif /* ndef S_IFBLK */ #ifdef S_IFCHR if ((x & S_IFMT) == S_IFCHR) *r |= MakeMap_Test_FlagsEnum_S_IFCHR; #endif /* ndef S_IFCHR */ #ifdef S_IFDIR if ((x & S_IFMT) == S_IFDIR) *r |= MakeMap_Test_FlagsEnum_S_IFDIR; #endif /* ndef S_IFDIR */ #ifdef S_IFIFO if ((x & S_IFMT) == S_IFIFO) *r |= MakeMap_Test_FlagsEnum_S_IFIFO; #endif /* ndef S_IFIFO */ #ifdef S_IFLNK if ((x & S_IFMT) == S_IFLNK) *r |= MakeMap_Test_FlagsEnum_S_IFLNK; #endif /* ndef S_IFLNK */ #ifdef S_IFMT if ((x & S_IFMT) == S_IFMT) *r |= MakeMap_Test_FlagsEnum_S_IFMT; #endif /* ndef S_IFMT */ #ifdef S_IFREG if ((x & S_IFMT) == S_IFREG) *r |= MakeMap_Test_FlagsEnum_S_IFREG; #endif /* ndef S_IFREG */ #ifdef S_IFSOCK if ((x & S_IFMT) == S_IFSOCK) *r |= MakeMap_Test_FlagsEnum_S_IFSOCK; #endif /* ndef S_IFSOCK */ return 0; } #ifdef HAVE_STRUCT_FOO int MakeMap_Test_FromFoo (struct MakeMap_Test_Foo *from, struct foo *to) { _cnm_return_val_if_overflow (int, from->foo, -1); #ifdef HAVE_STRUCT_FOO_AUTOCONF_ME _cnm_return_val_if_overflow (gint64, from->autoconf_me, -1); #endif /* ndef HAVE_STRUCT_FOO_AUTOCONF_ME */ memset (to, 0, sizeof(*to)); to->foo = from->foo; to->p = from->p; #ifdef HAVE_STRUCT_FOO_AUTOCONF_ME to->autoconf_me = from->autoconf_me; #endif /* ndef HAVE_STRUCT_FOO_AUTOCONF_ME */ return 0; } #endif /* ndef HAVE_STRUCT_FOO */ #ifdef HAVE_STRUCT_FOO int MakeMap_Test_ToFoo (struct foo *from, struct MakeMap_Test_Foo *to) { _cnm_return_val_if_overflow (int, from->foo, -1); #ifdef HAVE_STRUCT_FOO_AUTOCONF_ME _cnm_return_val_if_overflow (gint64, from->autoconf_me, -1); #endif /* ndef HAVE_STRUCT_FOO_AUTOCONF_ME */ memset (to, 0, sizeof(*to)); to->foo = from->foo; to->p = from->p; #ifdef HAVE_STRUCT_FOO_AUTOCONF_ME to->autoconf_me = from->autoconf_me; #endif /* ndef HAVE_STRUCT_FOO_AUTOCONF_ME */ return 0; } #endif /* ndef HAVE_STRUCT_FOO */ #ifdef HAVE_STRUCT_FOO_HOLDER int MakeMap_Test_FromFooHolder (struct MakeMap_Test_FooHolder *from, struct foo_holder *to) { memset (to, 0, sizeof(*to)); if (MakeMap_Test_FromFoo (&from->foo, &to->foo) != 0) { return -1; } if (MakeMap_Test_FromTestEnum (from->mode, &to->mode) != 0) { return -1; } return 0; } #endif /* ndef HAVE_STRUCT_FOO_HOLDER */ #ifdef HAVE_STRUCT_FOO_HOLDER int MakeMap_Test_ToFooHolder (struct foo_holder *from, struct MakeMap_Test_FooHolder *to) { memset (to, 0, sizeof(*to)); if (MakeMap_Test_ToFoo (&from->foo, &to->foo) != 0) { return -1; } if (MakeMap_Test_ToTestEnum (from->mode, &to->mode) != 0) { return -1; } return 0; } #endif /* ndef HAVE_STRUCT_FOO_HOLDER */ int MakeMap_Test_FromSimpleFlagsEnum (int x, int *r) { *r = 0; if ((x & MakeMap_Test_SimpleFlagsEnum_A) == MakeMap_Test_SimpleFlagsEnum_A) #ifdef A *r |= A; #else /* def A */ {errno = EINVAL; return -1;} #endif /* ndef A */ if ((x & MakeMap_Test_SimpleFlagsEnum_B) == MakeMap_Test_SimpleFlagsEnum_B) #ifdef B *r |= B; #else /* def B */ {errno = EINVAL; return -1;} #endif /* ndef B */ if ((x & MakeMap_Test_SimpleFlagsEnum_C) == MakeMap_Test_SimpleFlagsEnum_C) #ifdef C *r |= C; #else /* def C */ {errno = EINVAL; return -1;} #endif /* ndef C */ if ((x & MakeMap_Test_SimpleFlagsEnum_D) == MakeMap_Test_SimpleFlagsEnum_D) #ifdef D *r |= D; #else /* def D */ {errno = EINVAL; return -1;} #endif /* ndef D */ if ((x & MakeMap_Test_SimpleFlagsEnum_None) == MakeMap_Test_SimpleFlagsEnum_None) #ifdef None *r |= None; #else /* def None */ {errno = EINVAL; return -1;} #endif /* ndef None */ if (x == 0) return 0; return 0; } int MakeMap_Test_ToSimpleFlagsEnum (int x, int *r) { *r = 0; if (x == 0) return 0; #ifdef A if ((x & A) == A) *r |= MakeMap_Test_SimpleFlagsEnum_A; #endif /* ndef A */ #ifdef B if ((x & B) == B) *r |= MakeMap_Test_SimpleFlagsEnum_B; #endif /* ndef B */ #ifdef C if ((x & C) == C) *r |= MakeMap_Test_SimpleFlagsEnum_C; #endif /* ndef C */ #ifdef D if ((x & D) == D) *r |= MakeMap_Test_SimpleFlagsEnum_D; #endif /* ndef D */ #ifdef None if ((x & None) == None) *r |= MakeMap_Test_SimpleFlagsEnum_None; #endif /* ndef None */ return 0; } int MakeMap_Test_FromTestEnum (gint64 x, gint64 *r) { *r = 0; if (x == MakeMap_Test_TestEnum_Bar) #ifdef Bar {*r = Bar; return 0;} #else /* def Bar */ {errno = EINVAL; return -1;} #endif /* ndef Bar */ if (x == MakeMap_Test_TestEnum_Baz) #ifdef Baz {*r = Baz; return 0;} #else /* def Baz */ {errno = EINVAL; return -1;} #endif /* ndef Baz */ if (x == MakeMap_Test_TestEnum_Foo) #ifdef Foo {*r = Foo; return 0;} #else /* def Foo */ {errno = EINVAL; return -1;} #endif /* ndef Foo */ if (x == MakeMap_Test_TestEnum_Qux) #ifdef Qux {*r = Qux; return 0;} #else /* def Qux */ {errno = EINVAL; return -1;} #endif /* ndef Qux */ if (x == 0) return 0; errno = EINVAL; return -1; } int MakeMap_Test_ToTestEnum (gint64 x, gint64 *r) { *r = 0; if (x == 0) return 0; #ifdef Bar if (x == Bar) {*r = MakeMap_Test_TestEnum_Bar; return 0;} #endif /* ndef Bar */ #ifdef Baz if (x == Baz) {*r = MakeMap_Test_TestEnum_Baz; return 0;} #endif /* ndef Baz */ #ifdef Foo if (x == Foo) {*r = MakeMap_Test_TestEnum_Foo; return 0;} #endif /* ndef Foo */ #ifdef Qux if (x == Qux) {*r = MakeMap_Test_TestEnum_Qux; return 0;} #endif /* ndef Qux */ errno = EINVAL; return -1; } int MakeMap_Rename_FromColors (int x, int *r) { *r = 0; if (x == MakeMap_Rename_Colors_Blue) #ifdef Blue {*r = Blue; return 0;} #else /* def Blue */ {errno = EINVAL; return -1;} #endif /* ndef Blue */ if (x == MakeMap_Rename_Colors_Green) #ifdef Green {*r = Green; return 0;} #else /* def Green */ {errno = EINVAL; return -1;} #endif /* ndef Green */ if (x == MakeMap_Rename_Colors_Red) #ifdef Red {*r = Red; return 0;} #else /* def Red */ {errno = EINVAL; return -1;} #endif /* ndef Red */ if (x == 0) return 0; errno = EINVAL; return -1; } int MakeMap_Rename_ToColors (int x, int *r) { *r = 0; if (x == 0) return 0; #ifdef Blue if (x == Blue) {*r = MakeMap_Rename_Colors_Blue; return 0;} #endif /* ndef Blue */ #ifdef Green if (x == Green) {*r = MakeMap_Rename_Colors_Green; return 0;} #endif /* ndef Green */ #ifdef Red if (x == Red) {*r = MakeMap_Rename_Colors_Red; return 0;} #endif /* ndef Red */ errno = EINVAL; return -1; }