diff options
author | lantw44 <lantw44@gmail.com> | 2013-01-26 20:31:45 +0800 |
---|---|---|
committer | lantw44 <lantw44@gmail.com> | 2013-01-26 20:31:45 +0800 |
commit | eec0ca07f5e2350120e417c08dd444edf4e9d306 (patch) | |
tree | 6d3a8c76760f5c240b49f016d2c4ae2b239f17a3 | |
parent | c41f897304100c89451e91acb0a47b3f07fc7b51 (diff) | |
download | sctjudge-eec0ca07f5e2350120e417c08dd444edf4e9d306.tar sctjudge-eec0ca07f5e2350120e417c08dd444edf4e9d306.tar.gz sctjudge-eec0ca07f5e2350120e417c08dd444edf4e9d306.tar.bz2 sctjudge-eec0ca07f5e2350120e417c08dd444edf4e9d306.tar.lz sctjudge-eec0ca07f5e2350120e417c08dd444edf4e9d306.tar.xz sctjudge-eec0ca07f5e2350120e417c08dd444edf4e9d306.tar.zst sctjudge-eec0ca07f5e2350120e417c08dd444edf4e9d306.zip |
修改檢查函式庫的部份,同時 l4basic 更新至 1.1 版
-rw-r--r-- | configure.ac | 28 | ||||
-rw-r--r-- | l4basic/COPYING | 25 | ||||
-rw-r--r-- | l4basic/Makefile | 10 | ||||
-rw-r--r-- | l4basic/README | 2 | ||||
-rw-r--r-- | l4basic/VERSION | 2 | ||||
-rw-r--r-- | l4basic/l4arg/Makefile | 16 | ||||
-rw-r--r-- | l4basic/l4bds/Makefile | 16 | ||||
-rw-r--r-- | l4basic/l4darr/Makefile | 16 | ||||
-rw-r--r-- | l4basic/l4darr/d1array.c | 1 | ||||
-rw-r--r-- | l4basic/l4darr/d1arrstr.c | 10 | ||||
-rw-r--r-- | l4basic/l4darr/l4darr.h | 4 |
11 files changed, 95 insertions, 35 deletions
diff --git a/configure.ac b/configure.ac index 7681714..65f58e6 100644 --- a/configure.ac +++ b/configure.ac @@ -103,24 +103,16 @@ fi # Checks for libraries. -checkliblist="pthread_create pthread_exit pthread_cancel pthread_join pthread_attr_init pthread_attr_destroy pthread_attr_setdetachstate pthread_mutex_init pthread_mutex_destroy pthread_mutex_lock pthread_mutex_unlock pthread_setcancelstate pthread_setcanceltype" - -for i in $checkliblist; do - AC_CHECK_LIB([pthread], $i, [true], - [AC_MSG_ERROR(Your POSIX Thread Library may not be properly installed)]) -done -LIBS="$LIBS -lpthread -lrt" - - -checkliblist="sem_init sem_destroy sem_wait sem_post" -for i in $checkliblist; do - AC_CHECK_LIB([c], $i, [true], [c_sem_notfound=yes]) - AC_CHECK_LIB([pthread], $i, [true], [pthread_sem_notfound=yes]) - if test x"${c_sem_notfound}" = xyes && test x"${pthread_sem_notfound}" = xyes - then - AC_MSG_ERROR(Your semaphore support may be incomplete) - fi -done +AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread -lrt"], + [test_nort=yes], [-lrt]) + +if test x"$test_nort" = xyes; then + AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], + [AC_MSG_ERROR([POSIX Thread Library is required])]) +fi + +AC_CHECK_LIB([c], [sem_timedwait], [true], + [AC_MSG_ERROR([Semaphore support is required])], ["$LIBS"]) if test x"${opt_cap}" = xyes; then diff --git a/l4basic/COPYING b/l4basic/COPYING new file mode 100644 index 0000000..b529e31 --- /dev/null +++ b/l4basic/COPYING @@ -0,0 +1,25 @@ +Copyright (c) 2012, 藍挺瑋 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/l4basic/Makefile b/l4basic/Makefile index cc3afdc..b0dd0c8 100644 --- a/l4basic/Makefile +++ b/l4basic/Makefile @@ -1,3 +1,4 @@ + .PHONY: all clean install uninstall all: $(MAKE) -C l4darr all @@ -8,5 +9,10 @@ clean: $(MAKE) -C l4bds clean $(MAKE) -C l4arg clean install: - @echo "You should statically link your program against it instead of installing it!" - + $(MAKE) -C l4darr install + $(MAKE) -C l4bds install + $(MAKE) -C l4arg install +uninstall: + $(MAKE) -C l4darr uninstall + $(MAKE) -C l4bds uninstall + $(MAKE) -C l4arg uninstall diff --git a/l4basic/README b/l4basic/README index fb2344a..67fda80 100644 --- a/l4basic/README +++ b/l4basic/README @@ -10,4 +10,4 @@ l4darr: 基本上這些函式庫都很小,所以請直接靜態連結到你的程式,不要安裝到系統上! 同時預設的 Makefile 也不提供建立動態函式庫的功能,有需要請自行處理! -本函式庫使用 Public Domain 釋出,歡迎自行修改以符合需求! +本程式是自由軟體,您可以依據 COPYING 檔案中的規範自由散布、修改這個軟體。 diff --git a/l4basic/VERSION b/l4basic/VERSION index 3eefcb9..9084fa2 100644 --- a/l4basic/VERSION +++ b/l4basic/VERSION @@ -1 +1 @@ -1.0.0 +1.1.0 diff --git a/l4basic/l4arg/Makefile b/l4basic/l4arg/Makefile index 8c23687..0f2ffe3 100644 --- a/l4basic/l4arg/Makefile +++ b/l4basic/l4arg/Makefile @@ -1,9 +1,14 @@ CC=cc AR=ar -RM=rm -CFLAGS=-Wall -g -I. -I../l4darr +RM=rm -f +INSTALL=install -m 644 +LOCAL_CFLAGS=-g +CFLAGS=-Wall -I. -I../l4darr $(LOCAL_CFLAGS) OBJ=toargv.o qarg.o LIBFILE=libl4arg.a +DESTDIR=/ +PREFIX=/usr/local +LIBDIR=$(DESTDIR)/$(PREFIX)/lib .PHONY: all clean @@ -11,4 +16,9 @@ all: $(LIBFILE) $(LIBFILE): $(OBJ) $(AR) rcs $(LIBFILE) $(OBJ) clean: - $(RM) -f $(LIBFILE) $(OBJ) + $(RM) $(LIBFILE) $(OBJ) +install: + mkdir -p $(LIBDIR) + $(INSTALL) $(LIBFILE) $(LIBDIR) +uninstall: + $(RM) $(LIBDIR)/$(LIBFILE) diff --git a/l4basic/l4bds/Makefile b/l4basic/l4bds/Makefile index 1691cee..c4c2caa 100644 --- a/l4basic/l4bds/Makefile +++ b/l4basic/l4bds/Makefile @@ -1,9 +1,14 @@ CC=cc AR=ar -RM=rm -CFLAGS=-Wall -g -I. +RM=rm -f +INSTALL=install -m 644 +LOCAL_CFLAGS=-g +CFLAGS=-Wall -I. $(LOCAL_CFLAGS) OBJ=list.o LIBFILE=libl4bds.a +DESTDIR=/ +PREFIX=/usr/local +LIBDIR=$(DESTDIR)/$(PREFIX)/lib .PHONY: all clean @@ -11,4 +16,9 @@ all: $(LIBFILE) $(LIBFILE): $(OBJ) $(AR) rcs $(LIBFILE) $(OBJ) clean: - $(RM) -f $(LIBFILE) $(OBJ) + $(RM) $(LIBFILE) $(OBJ) +install: + mkdir -p $(LIBDIR) + $(INSTALL) -c $(LIBFILE) $(LIBDIR) +uninstall: + $(RM) $(LIBDIR)/$(LIBFILE) diff --git a/l4basic/l4darr/Makefile b/l4basic/l4darr/Makefile index 3bc40c7..4593ccf 100644 --- a/l4basic/l4darr/Makefile +++ b/l4basic/l4darr/Makefile @@ -1,9 +1,14 @@ CC=cc AR=ar -RM=rm -CFLAGS=-Wall -g -I. +RM=rm -f +INSTALL=install -m 644 +LOCAL_CFLAGS=-g +CFLAGS=-Wall -I. $(LOCAL_CFLAGS) OBJ=d1array.o d1arrstr.o d2array.o LIBFILE=libl4darr.a +DESTDIR=/ +PREFIX=/usr/local +LIBDIR=$(DESTDIR)/$(PREFIX)/lib .PHONY: all clean @@ -11,4 +16,9 @@ all: $(LIBFILE) $(LIBFILE): $(OBJ) $(AR) rcs $(LIBFILE) $(OBJ) clean: - $(RM) -f $(LIBFILE) $(OBJ) + $(RM) $(LIBFILE) $(OBJ) +install: + mkdir -p $(LIBDIR) + $(INSTALL) -c $(LIBFILE) $(LIBDIR) +uninstall: + $(RM) $(LIBDIR)/$(LIBFILE) diff --git a/l4basic/l4darr/d1array.c b/l4basic/l4darr/d1array.c index 4091358..b14bbea 100644 --- a/l4basic/l4darr/d1array.c +++ b/l4basic/l4darr/d1array.c @@ -127,5 +127,6 @@ L4DA* l4da_make_struct(void* data, int itemsize, int len, int maxlen){ arr->arr_itemsize = itemsize; arr->arr_curlen = len; arr->arr_maxlen = maxlen; + arr->arr_data = data; return arr; } diff --git a/l4basic/l4darr/d1arrstr.c b/l4basic/l4darr/d1arrstr.c index 212760e..2c6e631 100644 --- a/l4basic/l4darr/d1arrstr.c +++ b/l4basic/l4darr/d1arrstr.c @@ -31,13 +31,17 @@ L4DA* l4da_filereadline_delim(FILE* infile, int chr){ } int c; char towrite; - do{ - c = getc(infile); + while((c = getc(infile)) != chr && !feof(infile)){ towrite = c; if(l4da_pushback(newarr, (void*)&towrite) < 0){ l4da_free(newarr); return NULL; } - }while(c != chr); + } + towrite = '\0'; + if(l4da_pushback(newarr, (void*)&towrite) < 0){ + l4da_free(newarr); + return NULL; + } return newarr; } diff --git a/l4basic/l4darr/l4darr.h b/l4basic/l4darr/l4darr.h index d4aab12..860f9b9 100644 --- a/l4basic/l4darr/l4darr.h +++ b/l4basic/l4darr/l4darr.h @@ -23,12 +23,13 @@ int l4da_setlen(L4DA*, int); int l4da_setmax(L4DA*, int); int l4da_strip(L4DA*); #define l4da_itemsize(arr) ((arr)->arr_itemsize) +#define l4da_data(arr) ((arr)->arr_data) #define l4da_v(arr, type, num) \ (*(((type*)((arr)->arr_data))+(num))) #define l4da_vp(arr, num) \ ((void*)(((char*)((arr)->arr_data))+(((arr)->arr_itemsize)*(num)))) -#define l4da_readline (l4da_filereadline_delim(stdin, '\n')) +#define l4da_readline() (l4da_filereadline_delim(stdin, '\n')) #define l4da_readline_delim(delim) (l4da_filereadline_delim(stdin, (delim))) #define l4da_filereadline(infile) (l4da_filereadline_delim((infile), '\n')) L4DA* l4da_filereadline_delim(FILE*, int); @@ -53,6 +54,7 @@ void l4da2_free(L4DA2*); #define l4da2_getlenx(arr) ((arr)->arr_lenx) #define l4da2_getleny(arr) ((arr)->arr_leny) #define l4da2_itemsize(arr) ((arr)->arr_itemsize) +#define l4da2_data(arr) ((arr)->arr_data) #define l4da2_v(arr, type, numx, numy) \ (*(((type*)((arr)->arr_data))+((numx)*(l4da2_getleny(arr)))+(numy))) #define l4da2_vp(arr, numx, numy) \ |