From 9817e365b151b73a2b960252580b1890ddd07358 Mon Sep 17 00:00:00 2001 From: doursse Date: Fri, 11 Apr 2008 05:59:42 +0000 Subject: [PATCH] fix gettimeofday on windows and add __UNUSED__ for unused parameters SVN revision: 34245 --- legacy/embryo/configure.in | 25 +++++++++++++++++++++---- legacy/embryo/src/bin/embryo_cc_sc.h | 7 +++++++ legacy/embryo/src/bin/embryo_cc_sc1.c | 4 ++-- legacy/embryo/src/bin/embryo_cc_sc4.c | 2 +- legacy/embryo/src/bin/embryo_cc_sc6.c | 15 ++++++++++----- legacy/embryo/src/lib/embryo_args.c | 2 +- legacy/embryo/src/lib/embryo_float.c | 26 +++++++++++++------------- legacy/embryo/src/lib/embryo_private.h | 6 ++++++ legacy/embryo/src/lib/embryo_rand.c | 4 ++-- legacy/embryo/src/lib/embryo_time.c | 23 ++--------------------- 10 files changed, 65 insertions(+), 49 deletions(-) diff --git a/legacy/embryo/configure.in b/legacy/embryo/configure.in index 4dec12012b..1fa0c5bbc1 100644 --- a/legacy/embryo/configure.in +++ b/legacy/embryo/configure.in @@ -29,10 +29,6 @@ SNAP=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $4);}'` version_info=`expr $VMAJ + $VMIN`":$VMIC:$VMIN" AC_SUBST(version_info) -AC_FUNC_ALLOCA - -AC_CHECK_FUNCS(gettimeofday) - WIN32_CFLAGS="" create_shared_lib="" case "$host_os" in @@ -41,15 +37,36 @@ case "$host_os" in AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed]) dnl needed for correct definition of EAPI AC_DEFINE(EFL_EMBRYO_BUILD, 1, [Define to mention that embryo is built]) + AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Defined to 1 (MinGW / CeGCC platform)]) if test "x$host_os" = "xcegcc" ; then WIN32_CFLAGS="-mwin32" fi create_shared_lib="-no-undefined" ;; + *) + AC_CHECK_FUNCS(gettimeofday) esac AC_SUBST(WIN32_CFLAGS) AC_SUBST(create_shared_lib) +dnl Checking for __attribute__ support +AC_MSG_CHECKING([for __attribute__]) +AC_CACHE_VAL(have___attribute__, + [ + AC_TRY_COMPILE([#include ], + [int func(int x); int foo(int x __attribute__ ((unused))) { exit(1); }], + [have___attribute__="yes"], + [have___attribute__="no"]) + ] +) + +if test "x${have___attribute__}" = "xyes" ; then + AC_DEFINE(HAVE___ATTRIBUTE__, 1, [Define to 1 if your compiler has __attribute__]) +fi +AC_MSG_RESULT(${have___attribute__}) + +AC_FUNC_ALLOCA + AC_CHECK_HEADERS(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file])) fnmatch_libs="" diff --git a/legacy/embryo/src/bin/embryo_cc_sc.h b/legacy/embryo/src/bin/embryo_cc_sc.h index 97bff61b8e..491a48f349 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc.h +++ b/legacy/embryo/src/bin/embryo_cc_sc.h @@ -29,6 +29,7 @@ */ #ifndef EMBRYO_CC_SC_H #define EMBRYO_CC_SC_H + #include #include #include @@ -36,6 +37,12 @@ #include "embryo_cc_osdefs.h" #include "embryo_cc_amx.h" +#if HAVE___ATTRIBUTE__ +#define __UNUSED__ __attribute__((unused)) +#else +#define __UNUSED__ +#endif + /* Note: the "cell" and "ucell" types are defined in AMX.H */ #define PUBLIC_CHAR '@' /* character that defines a function "public" */ diff --git a/legacy/embryo/src/bin/embryo_cc_sc1.c b/legacy/embryo/src/bin/embryo_cc_sc1.c index d3edc6c08b..18fe267e97 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc1.c +++ b/legacy/embryo/src/bin/embryo_cc_sc1.c @@ -116,7 +116,7 @@ static int *wqptr; /* pointer to next entry */ static char binfname[_MAX_PATH]; /* binary file name */ int -main(int argc, char *argv[], char *env[]) +main(int argc, char *argv[], char *env[] __UNUSED__) { char argv0[_MAX_PATH]; int i; @@ -597,7 +597,7 @@ initglobals(void) static void parseoptions(int argc, char **argv, char *iname, char *oname, - char *pname, char *rname) + char *pname __UNUSED__, char *rname __UNUSED__) { char str[PATH_MAX]; int i, stack_size; diff --git a/legacy/embryo/src/bin/embryo_cc_sc4.c b/legacy/embryo/src/bin/embryo_cc_sc4.c index 372ca65c53..1f0dca6813 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc4.c +++ b/legacy/embryo/src/bin/embryo_cc_sc4.c @@ -215,7 +215,7 @@ endexpr(int fullexpr) * Global references: funcstatus (referred to only) */ void -startfunc(char *fname) +startfunc(char *fname __UNUSED__) { stgwrite("\tproc"); stgwrite("\n"); diff --git a/legacy/embryo/src/bin/embryo_cc_sc6.c b/legacy/embryo/src/bin/embryo_cc_sc6.c index f620ebda82..ad3c5551d9 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc6.c +++ b/legacy/embryo/src/bin/embryo_cc_sc6.c @@ -209,8 +209,9 @@ write_encoded(FILE * fbin, ucell * c, int num) #if defined __BORLANDC__ || defined __WATCOMC__ #pragma argsused #endif + static cell -noop(FILE * fbin, char *params, cell opcode) +noop(FILE * fbin __UNUSED__, char *params __UNUSED__, cell opcode __UNUSED__) { return 0; } @@ -218,8 +219,9 @@ noop(FILE * fbin, char *params, cell opcode) #if defined __BORLANDC__ || defined __WATCOMC__ #pragma argsused #endif + static cell -parm0(FILE * fbin, char *params, cell opcode) +parm0(FILE * fbin, char *params __UNUSED__, cell opcode) { if (fbin != NULL) write_encoded(fbin, (ucell *) & opcode, 1); @@ -257,8 +259,9 @@ parm2(FILE * fbin, char *params, cell opcode) #if defined __BORLANDC__ || defined __WATCOMC__ #pragma argsused #endif + static cell -do_dump(FILE * fbin, char *params, cell opcode) +do_dump(FILE * fbin, char *params, cell opcode __UNUSED__) { ucell p; int num = 0; @@ -422,8 +425,9 @@ do_switch(FILE * fbin, char *params, cell opcode) #if defined __BORLANDC__ || defined __WATCOMC__ #pragma argsused #endif + static cell -do_case(FILE * fbin, char *params, cell opcode) +do_case(FILE * fbin, char *params, cell opcode __UNUSED__) { int i; ucell p, v; @@ -445,8 +449,9 @@ do_case(FILE * fbin, char *params, cell opcode) #if defined __BORLANDC__ || defined __WATCOMC__ #pragma argsused #endif + static cell -curfile(FILE * fbin, char *params, cell opcode) +curfile(FILE * fbin __UNUSED__, char *params, cell opcode __UNUSED__) { fcurrent = (int)hex2long(params, NULL); return 0; diff --git a/legacy/embryo/src/lib/embryo_args.c b/legacy/embryo/src/lib/embryo_args.c index 952897ffd9..cd0de560e8 100644 --- a/legacy/embryo/src/lib/embryo_args.c +++ b/legacy/embryo/src/lib/embryo_args.c @@ -12,7 +12,7 @@ /* exported args api */ static Embryo_Cell -_embryo_args_numargs(Embryo_Program *ep, Embryo_Cell *params) +_embryo_args_numargs(Embryo_Program *ep, Embryo_Cell *params __UNUSED__) { Embryo_Header *hdr; unsigned char *data; diff --git a/legacy/embryo/src/lib/embryo_float.c b/legacy/embryo/src/lib/embryo_float.c index aea1d51d70..12f0353c30 100644 --- a/legacy/embryo/src/lib/embryo_float.c +++ b/legacy/embryo/src/lib/embryo_float.c @@ -60,7 +60,7 @@ _embryo_fp_degrees_to_radians(float angle, int radix) /* exported float api */ static Embryo_Cell -_embryo_fp(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = long value to convert to a float */ float f; @@ -89,7 +89,7 @@ _embryo_fp_str(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_mul(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_mul(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand 1 */ /* params[2] = float operand 2 */ @@ -101,7 +101,7 @@ _embryo_fp_mul(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_div(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_div(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float dividend (top) */ /* params[2] = float divisor (bottom) */ @@ -113,7 +113,7 @@ _embryo_fp_div(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_add(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_add(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand 1 */ /* params[2] = float operand 2 */ @@ -125,7 +125,7 @@ _embryo_fp_add(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_sub(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_sub(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand 1 */ /* params[2] = float operand 2 */ @@ -138,7 +138,7 @@ _embryo_fp_sub(Embryo_Program *ep, Embryo_Cell *params) /* Return fractional part of float */ static Embryo_Cell -_embryo_fp_fract(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_fract(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand */ float f; @@ -151,7 +151,7 @@ _embryo_fp_fract(Embryo_Program *ep, Embryo_Cell *params) /* Return integer part of float, rounded */ static Embryo_Cell -_embryo_fp_round(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_round(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand */ /* params[2] = Type of rounding (cell) */ @@ -179,7 +179,7 @@ _embryo_fp_round(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_cmp(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_cmp(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand 1 */ /* params[2] = float operand 2 */ @@ -211,7 +211,7 @@ _embryo_fp_sqroot(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_power(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_power(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand 1 */ /* params[2] = float operand 2 */ @@ -245,7 +245,7 @@ _embryo_fp_log(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_sin(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_sin(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand 1 (angle) */ /* params[2] = float operand 2 (radix) */ @@ -259,7 +259,7 @@ _embryo_fp_sin(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_cos(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_cos(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand 1 (angle) */ /* params[2] = float operand 2 (radix) */ @@ -273,7 +273,7 @@ _embryo_fp_cos(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_tan(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_tan(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand 1 (angle) */ /* params[2] = float operand 2 (radix) */ @@ -287,7 +287,7 @@ _embryo_fp_tan(Embryo_Program *ep, Embryo_Cell *params) } static Embryo_Cell -_embryo_fp_abs(Embryo_Program *ep, Embryo_Cell *params) +_embryo_fp_abs(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand */ float f; diff --git a/legacy/embryo/src/lib/embryo_private.h b/legacy/embryo/src/lib/embryo_private.h index cc5a4f24b1..6569ebabb0 100644 --- a/legacy/embryo/src/lib/embryo_private.h +++ b/legacy/embryo/src/lib/embryo_private.h @@ -39,6 +39,12 @@ void *alloca (size_t); # endif #endif +#if HAVE___ATTRIBUTE__ +#define __UNUSED__ __attribute__((unused)) +#else +#define __UNUSED__ +#endif + typedef enum _Embryo_Opcode Embryo_Opcode; enum _Embryo_Opcode diff --git a/legacy/embryo/src/lib/embryo_rand.c b/legacy/embryo/src/lib/embryo_rand.c index 28804c6b25..e04a5aef61 100644 --- a/legacy/embryo/src/lib/embryo_rand.c +++ b/legacy/embryo/src/lib/embryo_rand.c @@ -3,13 +3,13 @@ /* exported random number api */ static Embryo_Cell -_embryo_rand_rand(Embryo_Program *ep, Embryo_Cell *params) +_embryo_rand_rand(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED__) { return (Embryo_Cell)(rand() & 0xffff); } static Embryo_Cell -_embryo_rand_randf(Embryo_Program *ep, Embryo_Cell *params) +_embryo_rand_randf(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED__) { double r; float f; diff --git a/legacy/embryo/src/lib/embryo_time.c b/legacy/embryo/src/lib/embryo_time.c index 5e03eb1834..beaa9b3a19 100644 --- a/legacy/embryo/src/lib/embryo_time.c +++ b/legacy/embryo/src/lib/embryo_time.c @@ -6,32 +6,13 @@ #include #ifndef HAVE_GETTIMEOFDAY -#ifdef WIN32 -#include - -static int gettimeofday (struct timeval *tv, void *unused) -{ - struct _timeb t; - - if (!tv) - return -1; - - _ftime (&t); - - tv->tv_sec = t.time; - tv->tv_usec = t.millitm * 1000; - - return 0; -} -#else -#error "Your platform isn't supported yet" -#endif +# error "Your platform isn't supported yet" #endif /* exported time api */ static Embryo_Cell -_embryo_time_seconds(Embryo_Program *ep, Embryo_Cell *params) +_embryo_time_seconds(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED__) { struct timeval timev; double t;