Browse Source

Remove pthread and rt

git-svn-id: https://klish.googlecode.com/svn/trunk@596 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 12 years ago
parent
commit
df92544a3b
7 changed files with 12 additions and 305 deletions
  1. 0 2
      Makefile.in
  2. 0 6
      clish/shell.h
  3. 0 1
      clish/shell/private.h
  4. 1 97
      clish/shell/shell_spawn.c
  5. 0 6
      config.h.in
  6. 10 157
      configure
  7. 1 36
      configure.ac

+ 0 - 2
Makefile.in

@@ -342,8 +342,6 @@ PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
-RT_CFLAGS = @RT_CFLAGS@
-RT_LIBS = @RT_LIBS@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@

+ 0 - 6
clish/shell.h

@@ -13,7 +13,6 @@
 #define _clish_shell_h
 
 #include <stdio.h>
-#include <pthread.h>
 
 #include "lub/c_decl.h"
 #include "lub/types.h"
@@ -326,11 +325,6 @@ FILE *clish_shell__get_ostream(const clish_shell_t * instance);
 void clish_shell__set_lockfile(clish_shell_t * instance, const char * path);
 char * clish_shell__get_lockfile(clish_shell_t * instance);
 int clish_shell__set_socket(clish_shell_t * instance, const char * path);
-int clish_shell_spawn(clish_shell_t * instance,
-	const pthread_attr_t * attr);
-int clish_shell_wait(clish_shell_t * instance);
-int clish_shell_spawn_and_wait(clish_shell_t * instance,
-	const pthread_attr_t * attr);
 void clish_shell_load_scheme(clish_shell_t * instance, const char * xml_path);
 int clish_shell_loop(clish_shell_t * instance);
 clish_shell_state_t clish_shell__get_state(const clish_shell_t * instance);

+ 0 - 1
clish/shell/private.h

@@ -59,7 +59,6 @@ struct clish_shell_s {
 	int depth;
 	konf_client_t *client;
 	char *lockfile;
-	pthread_t pthread;
 	char *default_shebang;
 	char *fifo_name; /* The name of temporary fifo file. */
 	bool_t interactive; /* Is shell interactive. */

+ 1 - 97
clish/shell/shell_spawn.c

@@ -8,9 +8,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
-
 #include <unistd.h>
-#include <pthread.h>
 #include <dirent.h>
 
 /*
@@ -98,7 +96,7 @@ void clish_shell_load_scheme(clish_shell_t * this, const char *xml_path)
 }
 
 /*-------------------------------------------------------- */
-static int _loop(clish_shell_t * this, bool_t is_thread)
+int clish_shell_loop(clish_shell_t *this)
 {
 	int running = 0;
 	int retval = SHELL_STATE_OK;
@@ -110,8 +108,6 @@ static int _loop(clish_shell_t * this, bool_t is_thread)
 	if (this && (SHELL_STATE_CLOSING == this->state))
 		return retval;
 
-	if (is_thread)
-		pthread_testcancel();
 	/* Loop reading and executing lines until the user quits */
 	while (!running) {
 		retval = SHELL_STATE_OK;
@@ -135,101 +131,9 @@ static int _loop(clish_shell_t * this, bool_t is_thread)
 			running = -1;
 		if (running)
 			running = clish_shell_pop_file(this);
-		/* test for cancellation */
-		if (is_thread)
-			pthread_testcancel();
-	}
-
-	return retval;
-}
-
-/*-------------------------------------------------------- */
-/*
- * This is invoked when the thread ends or is cancelled.
- */
-static void clish_shell_thread_cleanup(clish_shell_t * this)
-{
-#ifdef __vxworks
-	int last_state;
-	/* we need to avoid recursion issues that exit in VxWorks */
-	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &last_state);
-#endif				/* __vxworks */
-
-/* Nothing to do now. The context will be free later. */
-
-#ifdef __vxworks
-	pthread_setcancelstate(last_state, &last_state);
-#endif				/* __vxworks */
-}
-
-/*-------------------------------------------------------- */
-/*
- * This provides the thread of execution for a shell instance
- */
-static void *clish_shell_thread(void *arg)
-{
-	clish_shell_t *this = arg;
-	int last_type;
-	int *res = NULL;
-
-	res = malloc(sizeof(*res));
-	*res = 0;
-	/* make sure we can only be cancelled at controlled points */
-	pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &last_type);
-	/* register a cancellation handler */
-	pthread_cleanup_push((void (*)(void *))clish_shell_thread_cleanup, this);
-
-	if (this)
-		*res = _loop(this, BOOL_TRUE);
-
-	/* be a good pthread citizen */
-	pthread_cleanup_pop(1);
-
-	return res;
-}
-
-/*-------------------------------------------------------- */
-int clish_shell_spawn(clish_shell_t *this,
-	const pthread_attr_t *attr)
-{
-	if (!this)
-		return -1;
-
-	return pthread_create(&this->pthread,
-		attr, clish_shell_thread, this);
-}
-
-/*-------------------------------------------------------- */
-int clish_shell_wait(clish_shell_t *this)
-{
-	void *res = NULL;
-	int retval = 0;
-
-	if (!this)
-		return -1;
-	(void)pthread_join(this->pthread, &res);
-	if (res) {
-		retval = *(int *)res;
-		free(res);
 	}
 
 	return retval;
 }
 
 /*-------------------------------------------------------- */
-int clish_shell_spawn_and_wait(clish_shell_t *this,
-	const pthread_attr_t *attr)
-{
-	if (clish_shell_spawn(this, attr) < 0)
-		return -1;
-
-	return clish_shell_wait(this);
-}
-
-/*-------------------------------------------------------- */
-int clish_shell_loop(clish_shell_t *this)
-{
-	return _loop(this, BOOL_FALSE);
-}
-
-/*-------------------------------------------------------- */

+ 0 - 6
config.h.in

@@ -18,18 +18,12 @@
 /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
 #undef HAVE_LANGINFO_CODESET
 
-/* Have POSIX real time library */
-#undef HAVE_LIBRT
-
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
-/* Define to 1 if you have the <pthread.h> header file. */
-#undef HAVE_PTHREAD_H
-
 /* Define to 1 if you have the <pwd.h> header file. */
 #undef HAVE_PWD_H
 

+ 10 - 157
configure

@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for klish 1.5.3.
+# Generated by GNU Autoconf 2.68 for klish 1.5.4.
 #
 # Report bugs to <serj.kalichev at gmail dot com>.
 #
@@ -570,8 +570,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='klish'
 PACKAGE_TARNAME='klish'
-PACKAGE_VERSION='1.5.3'
-PACKAGE_STRING='klish 1.5.3'
+PACKAGE_VERSION='1.5.4'
+PACKAGE_STRING='klish 1.5.4'
 PACKAGE_BUGREPORT='serj.kalichev at gmail dot com'
 PACKAGE_URL=''
 
@@ -615,8 +615,6 @@ ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
-RT_CFLAGS
-RT_LIBS
 TINYXML_CXXFLAGS
 TINYXML_LIBS
 TINYRL_CFLAGS
@@ -755,7 +753,6 @@ with_sysroot
 enable_libtool_lock
 enable_dependency_tracking
 enable_debug
-with_rt
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1312,7 +1309,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures klish 1.5.3 to adapt to many kinds of systems.
+\`configure' configures klish 1.5.4 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1382,7 +1379,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of klish 1.5.3:";;
+     short | recursive ) echo "Configuration of klish 1.5.4:";;
    esac
   cat <<\_ACEOF
 
@@ -1407,7 +1404,6 @@ Optional Packages:
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-sysroot=DIR Search for dependent libraries within DIR
                         (or the compiler's sysroot if not specified).
-  --with-rt=DIR           Use POSIX real time library distribution in DIR
 
 Some influential environment variables:
   CC          C compiler command
@@ -1488,7 +1484,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-klish configure 1.5.3
+klish configure 1.5.4
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2156,7 +2152,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by klish $as_me 1.5.3, which was
+It was created by klish $as_me 1.5.4, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -15762,7 +15758,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='klish'
- VERSION='1.5.3'
+ VERSION='1.5.4'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -16366,149 +16362,6 @@ fi
 
 
 
-################################
-# Check for the PTHREAD library
-################################
-#C_ARG_WITH(pthread,
-#           [AS_HELP_STRING([--with-pthread=DIR],
-#                           [Use POSIX threads library distribution in DIR])
-#           ])
-
-for ac_header in pthread.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
-if test "x$ac_cv_header_pthread_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_PTHREAD_H 1
-_ACEOF
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5
-$as_echo_n "checking for library containing pthread_create... " >&6; }
-if ${ac_cv_search_pthread_create+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pthread_create ();
-int
-main ()
-{
-return pthread_create ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' pthread; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_pthread_create=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if ${ac_cv_search_pthread_create+:} false; then :
-  break
-fi
-done
-if ${ac_cv_search_pthread_create+:} false; then :
-
-else
-  ac_cv_search_pthread_create=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5
-$as_echo "$ac_cv_search_pthread_create" >&6; }
-ac_res=$ac_cv_search_pthread_create
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-else
-   as_fn_error $? "Cannot find the POSIX threads library" "$LINENO" 5
-
-fi
-
-
-fi
-
-done
-
-
-################################
-# Check for the RT library
-################################
-
-# Check whether --with-rt was given.
-if test "${with_rt+set}" = set; then :
-  withval=$with_rt;
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
-$as_echo_n "checking for clock_gettime in -lrt... " >&6; }
-if ${ac_cv_lib_rt_clock_gettime+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lrt  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char clock_gettime ();
-int
-main ()
-{
-return clock_gettime ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_rt_clock_gettime=yes
-else
-  ac_cv_lib_rt_clock_gettime=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
-$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; }
-if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then :
-
-
-$as_echo "#define HAVE_LIBRT /**/" >>confdefs.h
-
-                if test "x$with_rt" = "x"; then
-                    RT_LIBS="-lrt"
-                else
-                    RT_CFLAGS="-I$with_rt/include"
-                    RT_LIBS="-L$with_rt/lib -lrt"
-                fi
-
-
-
-fi
-
-
 ################################
 # Search for network functions (like connect())
 ################################
@@ -17259,7 +17112,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by klish $as_me 1.5.3, which was
+This file was extended by klish $as_me 1.5.4, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -17325,7 +17178,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-klish config.status 1.5.3
+klish config.status 1.5.4
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 

+ 1 - 36
configure.ac

@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 m4_define([MAJOR_VERSION], 1)
 m4_define([MINOR_VERSION], 5)
-m4_define([MICRO_VERSION], 3)
+m4_define([MICRO_VERSION], 4)
 
 AC_PREREQ(2.59)
 AC_INIT([klish],
@@ -100,41 +100,6 @@ fi
 AC_SUBST(TINYXML_LIBS)
 AC_SUBST(TINYXML_CXXFLAGS)
 
-################################
-# Check for the PTHREAD library
-################################
-#C_ARG_WITH(pthread,
-#           [AS_HELP_STRING([--with-pthread=DIR],
-#                           [Use POSIX threads library distribution in DIR])
-#           ])
-
-AC_CHECK_HEADERS(pthread.h,
-	[ AC_SEARCH_LIBS([pthread_create], [pthread], [],
-		[ AC_MSG_ERROR([Cannot find the POSIX threads library])
-	])
-])
-
-################################
-# Check for the RT library
-################################
-AC_ARG_WITH(rt,
-            [AS_HELP_STRING([--with-rt=DIR],
-                            [Use POSIX real time library distribution in DIR])])
-
-AC_CHECK_LIB(rt, 
-             clock_gettime, 
-             [
-                AC_DEFINE([HAVE_LIBRT], [], [Have POSIX real time library])
-                if test "x$with_rt" = "x"; then
-                    RT_LIBS="-lrt"
-                else
-                    RT_CFLAGS="-I$with_rt/include"
-                    RT_LIBS="-L$with_rt/lib -lrt"
-                fi
-                AC_SUBST(RT_LIBS)
-                AC_SUBST(RT_CFLAGS)
-             ])
-
 ################################
 # Search for network functions (like connect())
 ################################