diff options
author | LAN-TW <lantw44@gmail.com> | 2014-01-13 00:58:53 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2014-01-13 00:58:53 +0800 |
commit | ba60d74714815661bc16f49ac02b5976abe78a5e (patch) | |
tree | 2da2b3586c18921892882d9c93e59bfe02b9539e | |
parent | 0c1dfc4fcbf9764633aa6cb1798e63d55af66752 (diff) | |
download | sp2013-ba60d74714815661bc16f49ac02b5976abe78a5e.tar sp2013-ba60d74714815661bc16f49ac02b5976abe78a5e.tar.gz sp2013-ba60d74714815661bc16f49ac02b5976abe78a5e.tar.bz2 sp2013-ba60d74714815661bc16f49ac02b5976abe78a5e.tar.lz sp2013-ba60d74714815661bc16f49ac02b5976abe78a5e.tar.xz sp2013-ba60d74714815661bc16f49ac02b5976abe78a5e.tar.zst sp2013-ba60d74714815661bc16f49ac02b5976abe78a5e.zip |
HW4: 更新 build system,檢查 C11 與 _Generic
-rwxr-xr-x | hw4/autogen.sh | 15 | ||||
-rw-r--r-- | hw4/configure.ac | 7 | ||||
-rw-r--r-- | hw4/l4basic.sed | 7 | ||||
-rw-r--r-- | hw4/l4basic/l4basic.patch | 46 | ||||
-rw-r--r-- | hw4/l4basic/l4basic.sed | 3 | ||||
-rw-r--r-- | hw4/l4basic/l4common.h | 18 | ||||
-rw-r--r-- | hw4/l4basic/l4list.c | 2 | ||||
-rw-r--r-- | hw4/l4basic/l4list.h | 2 | ||||
-rw-r--r-- | hw4/l4basic/l4posix.c | 2 | ||||
-rw-r--r-- | hw4/l4basic/l4posix.h | 2 | ||||
-rw-r--r-- | hw4/l4basic/l4str.c | 2 | ||||
-rw-r--r-- | hw4/l4basic/l4str.h | 2 |
12 files changed, 76 insertions, 32 deletions
diff --git a/hw4/autogen.sh b/hw4/autogen.sh index 2f3a1fc..3e7805e 100755 --- a/hw4/autogen.sh +++ b/hw4/autogen.sh @@ -12,14 +12,19 @@ generate_file () autoreconf -iv [ -z "$1" ] && exit 0 -mkdir -p "l4basic" -git clone "$1" "l4basic-tmp" -cd "l4basic-tmp" +echo "==> Downloading l4basic files" + +git clone "$1" "tmp" +cd "tmp" for i in l4common.h l4list.[ch] l4posix.[ch] l4str.[ch] do - generate_file "$i" "../l4basic.sed" + generate_file "$i" "../l4basic/l4basic.sed" done +cd "../l4basic" +echo "==> Applying patch for l4basic" +patch -p0 < "../l4basic/l4basic.patch" + cd ".." -rm -rf "l4basic-tmp" +rm -rf "tmp" diff --git a/hw4/configure.ac b/hw4/configure.ac index e57b5bc..255a1b0 100644 --- a/hw4/configure.ac +++ b/hw4/configure.ac @@ -1,6 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. +AC_PREREQ([2.69.56]) AC_INIT([cgish-httpd], [1]) AC_CONFIG_SRCDIR([chttpd-main.c]) AC_CONFIG_HEADERS([config.h]) @@ -8,9 +9,11 @@ AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) AM_SILENT_RULES([yes]) + # Checks for programs. -AC_PROG_CC([clang gcc cl cc]) -AC_PROG_CC_C99 +AC_PROG_CC([clang gcc cc]) +AC_PROG_CC_STDC +AC_C__GENERIC AC_PROG_RANLIB if test x"${ac_cv_prog_cc_c99}" = xno; then diff --git a/hw4/l4basic.sed b/hw4/l4basic.sed deleted file mode 100644 index 74725ca..0000000 --- a/hw4/l4basic.sed +++ /dev/null @@ -1,7 +0,0 @@ -1i\ -#include "memwrap.h" -1i\ -/* This file is modified by autogen.sh */ -s/malloc/xmalloc/g -s/realloc/xrealloc/g -s/strdup/xstrdup/g diff --git a/hw4/l4basic/l4basic.patch b/hw4/l4basic/l4basic.patch new file mode 100644 index 0000000..1fcafed --- /dev/null +++ b/hw4/l4basic/l4basic.patch @@ -0,0 +1,46 @@ +--- l4common.h.org 2014-01-13 00:43:28.406867323 +0800 ++++ l4common.h 2014-01-13 00:48:49.384892938 +0800 +@@ -2,31 +2,39 @@ + #ifndef LBS_COMMON_H + #define LBS_COMMON_H + ++#ifdef HAVE_CONFIG_H ++# include "config.h" ++#endif ++ + #include <stddef.h> + + #ifdef __STDC_VERSION__ + # include <stdbool.h> + # if __STDC_VERSION__ >= 201112L + # define LBS_COMMON_ISO_C11 +-# define LBS_COMMON_CHECK_TYPE(x,type) (_Generic ((x), type: (x))) + # else + # define LBS_COMMON_ISO_C99 +-# define LBS_COMMON_CHECK_TYPE(x,type) (x) + # endif + #else + # ifdef __cplusplus + # define LBS_COMMON_CXX +-# define LBS_COMMON_CHECK_TYPE(x,type) (x) + # else + # define bool char + # define true 1 + # define false 0 + # define inline + # define LBS_COMMON_ISO_C89 +-# define LBS_COMMON_CHECK_TYPE(x,type) (x) + # endif /* __cplusplus */ + #endif /* __STDC_VERSION__ */ + ++#ifdef HAVE_C__GENERIC ++# define LBS_COMMON_CHECK_TYPE(x,type) (_Generic ((x), type: (x))) ++#else ++# define LBS_COMMON_CHECK_TYPE(x,type) (x) ++#endif ++ ++#include "memwrap.h" ++ + #define LBS_COMMON_NULL_PTR ((void*)NULL) + #define LBS_COMMON_DEFINE_GETTER(ns,xt,m,mt) \ + static inline mt ns ## _get_ ## m (xt x) { \ diff --git a/hw4/l4basic/l4basic.sed b/hw4/l4basic/l4basic.sed new file mode 100644 index 0000000..bd5c488 --- /dev/null +++ b/hw4/l4basic/l4basic.sed @@ -0,0 +1,3 @@ +s/malloc/xmalloc/g +s/realloc/xrealloc/g +s/strdup/xstrdup/g diff --git a/hw4/l4basic/l4common.h b/hw4/l4basic/l4common.h index c41539c..a97c815 100644 --- a/hw4/l4basic/l4common.h +++ b/hw4/l4basic/l4common.h @@ -1,34 +1,40 @@ -#include "memwrap.h" -/* This file is modified by autogen.sh */ /* vim: set sw=4 ts=4 sts=4 et: */ #ifndef LBS_COMMON_H #define LBS_COMMON_H +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <stddef.h> #ifdef __STDC_VERSION__ # include <stdbool.h> # if __STDC_VERSION__ >= 201112L # define LBS_COMMON_ISO_C11 -# define LBS_COMMON_CHECK_TYPE(x,type) (_Generic ((x), type: (x))) # else # define LBS_COMMON_ISO_C99 -# define LBS_COMMON_CHECK_TYPE(x,type) (x) # endif #else # ifdef __cplusplus # define LBS_COMMON_CXX -# define LBS_COMMON_CHECK_TYPE(x,type) (x) # else # define bool char # define true 1 # define false 0 # define inline # define LBS_COMMON_ISO_C89 -# define LBS_COMMON_CHECK_TYPE(x,type) (x) # endif /* __cplusplus */ #endif /* __STDC_VERSION__ */ +#ifdef HAVE_C__GENERIC +# define LBS_COMMON_CHECK_TYPE(x,type) (_Generic ((x), type: (x))) +#else +# define LBS_COMMON_CHECK_TYPE(x,type) (x) +#endif + +#include "memwrap.h" + #define LBS_COMMON_NULL_PTR ((void*)NULL) #define LBS_COMMON_DEFINE_GETTER(ns,xt,m,mt) \ static inline mt ns ## _get_ ## m (xt x) { \ diff --git a/hw4/l4basic/l4list.c b/hw4/l4basic/l4list.c index 3569b19..a5147d3 100644 --- a/hw4/l4basic/l4list.c +++ b/hw4/l4basic/l4list.c @@ -1,5 +1,3 @@ -#include "memwrap.h" -/* This file is modified by autogen.sh */ /* vim: set sw=4 ts=4 sts=4 et: */ #include "l4list.h" diff --git a/hw4/l4basic/l4list.h b/hw4/l4basic/l4list.h index 00dba10..3def6e6 100644 --- a/hw4/l4basic/l4list.h +++ b/hw4/l4basic/l4list.h @@ -1,5 +1,3 @@ -#include "memwrap.h" -/* This file is modified by autogen.sh */ /* vim: set sw=4 ts=4 sts=4 et: */ #ifndef LBS_LIST_H #define LBS_LIST_H diff --git a/hw4/l4basic/l4posix.c b/hw4/l4basic/l4posix.c index 82b42a0..895fece 100644 --- a/hw4/l4basic/l4posix.c +++ b/hw4/l4basic/l4posix.c @@ -1,5 +1,3 @@ -#include "memwrap.h" -/* This file is modified by autogen.sh */ /* vim: set sw=4 ts=4 sts=4 et: */ #define _POSIX_C_SOURCE 200809L #define _XOPEN_SOURCE 700 diff --git a/hw4/l4basic/l4posix.h b/hw4/l4basic/l4posix.h index a368609..8b15ce0 100644 --- a/hw4/l4basic/l4posix.h +++ b/hw4/l4basic/l4posix.h @@ -1,5 +1,3 @@ -#include "memwrap.h" -/* This file is modified by autogen.sh */ /* vim: set sw=4 ts=4 sts=4 et: */ #ifndef LBS_POSIX_H #define LBS_POSIX_H diff --git a/hw4/l4basic/l4str.c b/hw4/l4basic/l4str.c index fa1d31b..ad8c2e6 100644 --- a/hw4/l4basic/l4str.c +++ b/hw4/l4basic/l4str.c @@ -1,5 +1,3 @@ -#include "memwrap.h" -/* This file is modified by autogen.sh */ /* vim: set sw=4 ts=4 sts=4 et: */ #include "l4str.h" diff --git a/hw4/l4basic/l4str.h b/hw4/l4basic/l4str.h index 40bb7fe..cda3c1d 100644 --- a/hw4/l4basic/l4str.h +++ b/hw4/l4basic/l4str.h @@ -1,5 +1,3 @@ -#include "memwrap.h" -/* This file is modified by autogen.sh */ /* vim: set sw=4 ts=4 sts=4 et: */ #ifndef LBS_STR_H #define LBS_STR_H |