Imported Upstream version 2.0.8
authorJelmer Vernooij <jelmer@samba.org>
Sun, 11 Aug 2013 14:27:20 +0000 (14:27 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 11 Aug 2013 14:27:20 +0000 (14:27 +0000)
93 files changed:
ABI/pytalloc-util-2.0.8.sigs [new file with mode: 0644]
ABI/talloc-2.0.8.sigs [new file with mode: 0644]
buildtools/compare_config_h3-exceptions.grep [new file with mode: 0644]
buildtools/compare_config_h3.sh
buildtools/scripts/abi_gen.sh
buildtools/update-waf.sh
buildtools/wafadmin/Tools/preproc.py
buildtools/wafadmin/Tools/python.py
buildtools/wafadmin/Utils.py
buildtools/wafsamba/__init__.py [new file with mode: 0644]
buildtools/wafsamba/configure_file.py [new file with mode: 0644]
buildtools/wafsamba/gccdeps.py
buildtools/wafsamba/generic_cc.py
buildtools/wafsamba/irixcc.py
buildtools/wafsamba/nothreads.py
buildtools/wafsamba/samba3.py
buildtools/wafsamba/samba_abi.py
buildtools/wafsamba/samba_autoconf.py
buildtools/wafsamba/samba_bundled.py
buildtools/wafsamba/samba_conftests.py
buildtools/wafsamba/samba_deps.py
buildtools/wafsamba/samba_dist.py
buildtools/wafsamba/samba_headers.py
buildtools/wafsamba/samba_install.py
buildtools/wafsamba/samba_optimisation.py
buildtools/wafsamba/samba_patterns.py
buildtools/wafsamba/samba_pidl.py
buildtools/wafsamba/samba_python.py
buildtools/wafsamba/samba_utils.py
buildtools/wafsamba/samba_version.py
buildtools/wafsamba/samba_wildcard.py
buildtools/wafsamba/stale_files.py
buildtools/wafsamba/symbols.py
buildtools/wafsamba/tests/__init__.py [new file with mode: 0644]
buildtools/wafsamba/tests/test_abi.py [new file with mode: 0644]
buildtools/wafsamba/tests/test_bundled.py [new file with mode: 0644]
buildtools/wafsamba/tests/test_utils.py [new file with mode: 0644]
buildtools/wafsamba/tru64cc.py
buildtools/wafsamba/wafsamba.py
buildtools/wafsamba/wscript
doc/context.png [new file with mode: 0644]
doc/context_tree.png [new file with mode: 0644]
doc/mainpage.dox
doc/stealing.png [new file with mode: 0644]
doc/tutorial_bestpractices.dox [new file with mode: 0644]
doc/tutorial_context.dox [new file with mode: 0644]
doc/tutorial_debugging.dox [new file with mode: 0644]
doc/tutorial_destructors.dox [new file with mode: 0644]
doc/tutorial_dts.dox [new file with mode: 0644]
doc/tutorial_introduction.dox [new file with mode: 0644]
doc/tutorial_pools.dox [new file with mode: 0644]
doc/tutorial_stealing.dox [new file with mode: 0644]
doxy.config
lib/replace/Makefile.in [deleted file]
lib/replace/README
lib/replace/aclocal.m4 [deleted file]
lib/replace/autoconf-2.60.m4 [deleted file]
lib/replace/autogen-autotools.sh [deleted file]
lib/replace/build_macros.m4 [deleted file]
lib/replace/config.guess [deleted file]
lib/replace/config.sub [deleted file]
lib/replace/configure.ac [deleted file]
lib/replace/libreplace.m4
lib/replace/libreplace_cc.m4
lib/replace/libreplace_network.m4
lib/replace/poll.c
lib/replace/replace-test.h
lib/replace/replace-testsuite.h [new file with mode: 0644]
lib/replace/replace.c
lib/replace/replace.h
lib/replace/samba.m4 [deleted file]
lib/replace/snprintf.c
lib/replace/strptime.c
lib/replace/strptime.m4
lib/replace/system/filesys.h
lib/replace/system/gssapi.h [new file with mode: 0644]
lib/replace/system/kerberos.h
lib/replace/test/incoherent_mmap.c [new file with mode: 0644]
lib/replace/test/main.c
lib/replace/test/testsuite.c
lib/replace/wscript
lib/replace/xattr.c [new file with mode: 0644]
pytalloc.c
script/abi_checks.sh [deleted file]
script/abi_checks_gcc.sh [deleted file]
script/mksigs.pl [deleted file]
script/mksyms.awk [deleted file]
script/mksyms.sh [deleted file]
script/release-script.sh [deleted file]
talloc.c
talloc.h
testsuite.c
wscript

diff --git a/ABI/pytalloc-util-2.0.8.sigs b/ABI/pytalloc-util-2.0.8.sigs
new file mode 100644 (file)
index 0000000..961c1a8
--- /dev/null
@@ -0,0 +1,6 @@
+pytalloc_CObject_FromTallocPtr: PyObject *(void *)
+pytalloc_Check: int (PyObject *)
+pytalloc_GetObjectType: PyTypeObject *(void)
+pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
+pytalloc_steal: PyObject *(PyTypeObject *, void *)
+pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
diff --git a/ABI/talloc-2.0.8.sigs b/ABI/talloc-2.0.8.sigs
new file mode 100644 (file)
index 0000000..15a9e95
--- /dev/null
@@ -0,0 +1,63 @@
+_talloc: void *(const void *, size_t)
+_talloc_array: void *(const void *, size_t, unsigned int, const char *)
+_talloc_free: int (void *, const char *)
+_talloc_get_type_abort: void *(const void *, const char *, const char *)
+_talloc_memdup: void *(const void *, const void *, size_t, const char *)
+_talloc_move: void *(const void *, const void *)
+_talloc_realloc: void *(const void *, void *, size_t, const char *)
+_talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
+_talloc_reference_loc: void *(const void *, const void *, const char *)
+_talloc_set_destructor: void (const void *, int (*)(void *))
+_talloc_steal_loc: void *(const void *, const void *, const char *)
+_talloc_zero: void *(const void *, size_t, const char *)
+_talloc_zero_array: void *(const void *, size_t, unsigned int, const char *)
+talloc_asprintf: char *(const void *, const char *, ...)
+talloc_asprintf_append: char *(char *, const char *, ...)
+talloc_asprintf_append_buffer: char *(char *, const char *, ...)
+talloc_autofree_context: void *(void)
+talloc_check_name: void *(const void *, const char *)
+talloc_disable_null_tracking: void (void)
+talloc_enable_leak_report: void (void)
+talloc_enable_leak_report_full: void (void)
+talloc_enable_null_tracking: void (void)
+talloc_enable_null_tracking_no_autofree: void (void)
+talloc_find_parent_byname: void *(const void *, const char *)
+talloc_free_children: void (void *)
+talloc_get_name: const char *(const void *)
+talloc_get_size: size_t (const void *)
+talloc_increase_ref_count: int (const void *)
+talloc_init: void *(const char *, ...)
+talloc_is_parent: int (const void *, const void *)
+talloc_named: void *(const void *, size_t, const char *, ...)
+talloc_named_const: void *(const void *, size_t, const char *)
+talloc_parent: void *(const void *)
+talloc_parent_name: const char *(const void *)
+talloc_pool: void *(const void *, size_t)
+talloc_realloc_fn: void *(const void *, void *, size_t)
+talloc_reference_count: size_t (const void *)
+talloc_reparent: void *(const void *, const void *, const void *)
+talloc_report: void (const void *, FILE *)
+talloc_report_depth_cb: void (const void *, int, int, void (*)(const void *, int, int, int, void *), void *)
+talloc_report_depth_file: void (const void *, int, int, FILE *)
+talloc_report_full: void (const void *, FILE *)
+talloc_set_abort_fn: void (void (*)(const char *))
+talloc_set_log_fn: void (void (*)(const char *))
+talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
+talloc_set_name: const char *(const void *, const char *, ...)
+talloc_set_name_const: void (const void *, const char *)
+talloc_show_parents: void (const void *, FILE *)
+talloc_strdup: char *(const void *, const char *)
+talloc_strdup_append: char *(char *, const char *)
+talloc_strdup_append_buffer: char *(char *, const char *)
+talloc_strndup: char *(const void *, const char *, size_t)
+talloc_strndup_append: char *(char *, const char *, size_t)
+talloc_strndup_append_buffer: char *(char *, const char *, size_t)
+talloc_total_blocks: size_t (const void *)
+talloc_total_size: size_t (const void *)
+talloc_unlink: int (const void *, void *)
+talloc_vasprintf: char *(const void *, const char *, va_list)
+talloc_vasprintf_append: char *(char *, const char *, va_list)
+talloc_vasprintf_append_buffer: char *(char *, const char *, va_list)
+talloc_version_major: int (void)
+talloc_version_minor: int (void)
diff --git a/buildtools/compare_config_h3-exceptions.grep b/buildtools/compare_config_h3-exceptions.grep
new file mode 100644 (file)
index 0000000..aa8851f
--- /dev/null
@@ -0,0 +1,10 @@
+^.define HAVE_.*KRB5
+^.define HAVE_.*KEYTAB
+^.define HAVE__ET_LIST
+^.define HAVE_LIBK5CRYPTO
+^.define HAVE_GSS
+^.define static
+^.define STATIC
+^.define PACKAGE
+^.define STRING_STATIC_MODULES
+^.define perfcount_test_init
index 294af30930dc40ccb9b7ec3926a88569199a6fe7..45be1ec34410eb625122f5257fe008a9789b361e 100755 (executable)
@@ -3,17 +3,25 @@
 # compare the generated config.h from a waf build with existing samba
 # build
 
-OLD_CONFIG=$HOME/samba_old/source3/include/config.h
+OLD_CONFIG=source3/include/autoconf/config.h
 if test "x$1" != "x" ; then
        OLD_CONFIG=$1
 fi
 
+NEW_CONFIG=bin/default/include/config.h
+if test "x$2" != "x" ; then
+       NEW_CONFIG=$2
+fi
+
+EXCEPTIONS=`dirname $0`/compare_config_h3-exceptions.grep
+
 if test "x$DIFF" = "x" ; then
        DIFF="comm -23"
 fi
 
-grep "^.define" bin/default/source3/include/config.h | sort > waf-config.h
-grep "^.define" $OLD_CONFIG | sort > old-config.h
+grep "^.define" $NEW_CONFIG | egrep -v -f $EXCEPTIONS | sort > waf-config.h
+grep "^.define" $OLD_CONFIG | egrep -v -f $EXCEPTIONS | sort > old-config.h
 
 $DIFF old-config.h waf-config.h
+rm -f old-config.h waf-config.h
 
index ed6f445519ed7118a06f49585a7fdee5f084534e..787718cb204ce6343036d420b680c2e43407f948 100755 (executable)
@@ -10,7 +10,7 @@ cat <<EOF
 set height 0
 set width 0
 EOF
-nm "$SHAREDLIB" | cut -d' ' -f2- | egrep '^[BDGTRVWS]' | grep -v @ | cut -c3- | sort | while read s; do
+nm "$SHAREDLIB" | cut -d' ' -f2- | egrep '^[BDGTRVWS]' | grep -v @ | egrep -v ' (__bss_start|_edata|_init|_fini|_end)' | cut -c3- | sort | while read s; do
     echo "echo $s: "
     echo p $s
 done
index cdb56c600a11194fb5553acfe806e01e0070efe4..277111feb4929d37cd4a77931b01af0da979f225 100755 (executable)
@@ -2,7 +2,7 @@
 # Update our copy of waf
 
 TARGETDIR="`dirname $0`"
-WORKDIR="`mktemp -d`"
+WORKDIR="`mktemp -d -t update-waf-XXXXXX`"
 
 mkdir -p "$WORKDIR"
 
index 5055456054b9612d8c28696b6ee50eb8df218d86..6c49326ec3e5945137972c5fab97226291e1118c 100644 (file)
@@ -555,8 +555,7 @@ def parse_char(txt):
                except KeyError: raise PreprocError("could not parse char literal '%s'" % txt)
 
 @Utils.run_once
-def tokenize(s):
-       """convert a string into a list of tokens (shlex.split does not apply to c/c++/d)"""
+def tokenize_private(s):
        ret = []
        for match in re_clexer.finditer(s):
                m = match.group
@@ -591,6 +590,10 @@ def tokenize(s):
                                break
        return ret
 
+def tokenize(s):
+       """convert a string into a list of tokens (shlex.split does not apply to c/c++/d)"""
+       return tokenize_private(s)[:]
+
 @Utils.run_once
 def define_name(line):
        return re_mac.match(line).group(0)
index 4f73081635e6ae59878c047c2a861c28ee376a3f..c2af3123f7270c8dceed9846c4241935cffe1c5e 100644 (file)
@@ -6,9 +6,9 @@
 "Python support"
 
 import os, sys
-import TaskGen, Utils, Utils, Runner, Options, Build
+import TaskGen, Utils, Options
 from Logs import debug, warn, info
-from TaskGen import extension, taskgen, before, after, feature
+from TaskGen import extension, before, after, feature
 from Configure import conf
 
 EXT_PY = ['.py']
@@ -136,8 +136,8 @@ def _get_python_variables(python_exe, variables, imports=['import sys']):
                        continue
                if s == 'None':
                        return_values.append(None)
-               elif s[0] == "'" and s[-1] == "'":
-                       return_values.append(s[1:-1])
+               elif (s[0] == "'" and s[-1] == "'") or (s[0] == '"' and s[-1] == '"'):
+                       return_values.append(eval(s))
                elif s[0].isdigit():
                        return_values.append(int(s))
                else: break
@@ -173,7 +173,7 @@ def check_python_headers(conf, mandatory=True):
                (python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS,
                 python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED,
                 python_MACOSX_DEPLOYMENT_TARGET) = \
-                       _get_python_variables(python, ["get_config_var('%s')" % x for x in v],
+                       _get_python_variables(python, ["get_config_var('%s') or ''" % x for x in v],
                                              ['from distutils.sysconfig import get_config_var'])
        except RuntimeError:
                conf.fatal("Python development headers not found (-v for details).")
@@ -310,7 +310,7 @@ def check_python_version(conf, minver=None):
        # Get python version string
        cmd = [python, "-c", "import sys\nfor x in sys.version_info: print(str(x))"]
        debug('python: Running python command %r' % cmd)
-       proc = Utils.pproc.Popen(cmd, stdout=Utils.pproc.PIPE)
+       proc = Utils.pproc.Popen(cmd, stdout=Utils.pproc.PIPE, shell=False)
        lines = proc.communicate()[0].split()
        assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines), lines)
        pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3], int(lines[4]))
@@ -329,14 +329,14 @@ def check_python_version(conf, minver=None):
                        if sys.platform == 'win32':
                                (python_LIBDEST, pydir) = \
                                                _get_python_variables(python,
-                                                                                         ["get_config_var('LIBDEST')",
-                                                                                          "get_python_lib(standard_lib=0, prefix=%r)" % conf.env['PREFIX']],
+                                                                                         ["get_config_var('LIBDEST') or ''",
+                                                                                          "get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']],
                                                                                          ['from distutils.sysconfig import get_config_var, get_python_lib'])
                        else:
                                python_LIBDEST = None
                                (pydir,) = \
                                                _get_python_variables(python,
-                                                                                         ["get_python_lib(standard_lib=0, prefix=%r)" % conf.env['PREFIX']],
+                                                                                         ["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']],
                                                                                          ['from distutils.sysconfig import get_config_var, get_python_lib'])
                        if python_LIBDEST is None:
                                if conf.env['LIBDIR']:
@@ -348,7 +348,7 @@ def check_python_version(conf, minver=None):
                        pyarchdir = conf.environ['PYTHONARCHDIR']
                else:
                        (pyarchdir,) = _get_python_variables(python,
-                                                                                       ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r)" % conf.env['PREFIX']],
+                                                                                       ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']],
                                                                                        ['from distutils.sysconfig import get_config_var, get_python_lib'])
                        if not pyarchdir:
                                pyarchdir = pydir
@@ -390,8 +390,10 @@ def detect(conf):
        if not python:
                conf.fatal('Could not find the path of the python executable')
 
-       v = conf.env
+       if conf.env.PYTHON != sys.executable:
+               warn("python executable '%s' different from sys.executable '%s'" % (conf.env.PYTHON, sys.executable))
 
+       v = conf.env
        v['PYCMD'] = '"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
        v['PYFLAGS'] = ''
        v['PYFLAGS_OPT'] = '-O'
index 41dad570ebe14551d734bc1935072a59549d1c60..91ded93b6e7d0ef194b2166e3d773b3f9fe7e8e5 100644 (file)
@@ -15,7 +15,7 @@ Utilities, the stable ones are the following:
 
        import stat
        def h_file(filename):
-               st = os.stat(filename)
+               st = os.lstat(filename)
                if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
                m = Utils.md5()
                m.update(str(st.st_mtime))
@@ -419,7 +419,7 @@ def pprint(col, str, label='', sep='\n'):
 def check_dir(dir):
        """If a folder doesn't exists, create it."""
        try:
-               os.stat(dir)
+               os.lstat(dir)
        except OSError:
                try:
                        os.makedirs(dir)
diff --git a/buildtools/wafsamba/__init__.py b/buildtools/wafsamba/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/buildtools/wafsamba/configure_file.py b/buildtools/wafsamba/configure_file.py
new file mode 100644 (file)
index 0000000..8e2ba3b
--- /dev/null
@@ -0,0 +1,44 @@
+# handle substitution of variables in .in files
+
+import Build, sys, Logs
+from samba_utils import *
+
+def subst_at_vars(task):
+    '''substiture @VAR@ style variables in a file'''
+
+    env = task.env
+    src = task.inputs[0].srcpath(env)
+    tgt = task.outputs[0].bldpath(env)
+
+    f = open(src, 'r')
+    s = f.read()
+    f.close()
+    # split on the vars
+    a = re.split('(@\w+@)', s)
+    out = []
+    for v in a:
+        if re.match('@\w+@', v):
+            vname = v[1:-1]
+            if not vname in task.env and vname.upper() in task.env:
+                vname = vname.upper()
+            if not vname in task.env:
+                Logs.error("Unknown substitution %s in %s" % (v, task.name))
+                sys.exit(1)
+            v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
+        out.append(v)
+    contents = ''.join(out)
+    f = open(tgt, 'w')
+    s = f.write(contents)
+    f.close()
+    return 0
+
+def CONFIGURE_FILE(bld, in_file, **kwargs):
+    '''configure file'''
+
+    base=os.path.basename(in_file)
+    t = bld.SAMBA_GENERATOR('INFILE_%s' % base,
+                            rule = subst_at_vars,
+                            source = in_file + '.in',
+                            target = in_file,
+                            vars = kwargs)
+Build.BuildContext.CONFIGURE_FILE = CONFIGURE_FILE
index 6600c9ca3ba563fde3d28061541606e1ab797905..2da42e63aea649284a76136af2b436dd2f4821d5 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # encoding: utf-8
 # Thomas Nagy, 2008-2010 (ita)
 
@@ -18,111 +17,111 @@ preprocessor_flag = '-MD'
 @feature('cc')
 @before('apply_core')
 def add_mmd_cc(self):
-       if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
-               self.env.append_value('CCFLAGS', preprocessor_flag)
+    if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
+        self.env.append_value('CCFLAGS', preprocessor_flag)
 
 @feature('cxx')
 @before('apply_core')
 def add_mmd_cxx(self):
-       if self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0:
-               self.env.append_value('CXXFLAGS', preprocessor_flag)
+    if self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0:
+        self.env.append_value('CXXFLAGS', preprocessor_flag)
 
 def scan(self):
-       "the scanner does not do anything initially"
-       nodes = self.generator.bld.node_deps.get(self.unique_id(), [])
-       names = []
-       return (nodes, names)
+    "the scanner does not do anything initially"
+    nodes = self.generator.bld.node_deps.get(self.unique_id(), [])
+    names = []
+    return (nodes, names)
 
 re_o = re.compile("\.o$")
 re_src = re.compile("^(\.\.)[\\/](.*)$")
 
 def post_run(self):
-       # The following code is executed by threads, it is not safe, so a lock is needed...
-
-       if getattr(self, 'cached', None):
-               return Task.Task.post_run(self)
-
-       name = self.outputs[0].abspath(self.env)
-       name = re_o.sub('.d', name)
-       txt = Utils.readf(name)
-       #os.unlink(name)
-
-       txt = txt.replace('\\\n', '')
-
-       lst = txt.strip().split(':')
-       val = ":".join(lst[1:])
-       val = val.split()
-
-       nodes = []
-       bld = self.generator.bld
-
-       f = re.compile("^("+self.env.variant()+"|\.\.)[\\/](.*)$")
-       for x in val:
-               if os.path.isabs(x):
-
-                       if not preproc.go_absolute:
-                               continue
-
-                       lock.acquire()
-                       try:
-                               node = bld.root.find_resource(x)
-                       finally:
-                               lock.release()
-               else:
-                       g = re.search(re_src, x)
-                       if g:
-                               x = g.group(2)
-                               lock.acquire()
-                               try:
-                                       node = bld.bldnode.parent.find_resource(x)
-                               finally:
-                                       lock.release()
-                       else:
-                               g = re.search(f, x)
-                               if g:
-                                       x = g.group(2)
-                                       lock.acquire()
-                                       try:
-                                               node = bld.srcnode.find_resource(x)
-                                       finally:
-                                               lock.release()
-
-               if id(node) == id(self.inputs[0]):
-                       # ignore the source file, it is already in the dependencies
-                       # this way, successful config tests may be retrieved from the cache
-                       continue
-
-               if not node:
-                       raise ValueError('could not find %r for %r' % (x, self))
-               else:
-                       nodes.append(node)
-
-       Logs.debug('deps: real scanner for %s returned %s' % (str(self), str(nodes)))
-
-       bld.node_deps[self.unique_id()] = nodes
-       bld.raw_deps[self.unique_id()] = []
-
-       try:
-               del self.cache_sig
-       except:
-               pass
-
-       Task.Task.post_run(self)
+    # The following code is executed by threads, it is not safe, so a lock is needed...
+
+    if getattr(self, 'cached', None):
+        return Task.Task.post_run(self)
+
+    name = self.outputs[0].abspath(self.env)
+    name = re_o.sub('.d', name)
+    txt = Utils.readf(name)
+    #os.unlink(name)
+
+    txt = txt.replace('\\\n', '')
+
+    lst = txt.strip().split(':')
+    val = ":".join(lst[1:])
+    val = val.split()
+
+    nodes = []
+    bld = self.generator.bld
+
+    f = re.compile("^("+self.env.variant()+"|\.\.)[\\/](.*)$")
+    for x in val:
+        if os.path.isabs(x):
+
+            if not preproc.go_absolute:
+                continue
+
+            lock.acquire()
+            try:
+                node = bld.root.find_resource(x)
+            finally:
+                lock.release()
+        else:
+            g = re.search(re_src, x)
+            if g:
+                x = g.group(2)
+                lock.acquire()
+                try:
+                    node = bld.bldnode.parent.find_resource(x)
+                finally:
+                    lock.release()
+            else:
+                g = re.search(f, x)
+                if g:
+                    x = g.group(2)
+                    lock.acquire()
+                    try:
+                        node = bld.srcnode.find_resource(x)
+                    finally:
+                        lock.release()
+
+        if id(node) == id(self.inputs[0]):
+            # ignore the source file, it is already in the dependencies
+            # this way, successful config tests may be retrieved from the cache
+            continue
+
+        if not node:
+            raise ValueError('could not find %r for %r' % (x, self))
+        else:
+            nodes.append(node)
+
+    Logs.debug('deps: real scanner for %s returned %s' % (str(self), str(nodes)))
+
+    bld.node_deps[self.unique_id()] = nodes
+    bld.raw_deps[self.unique_id()] = []
+
+    try:
+        del self.cache_sig
+    except:
+        pass
+
+    Task.Task.post_run(self)
 
 import Constants, Utils
 def sig_implicit_deps(self):
-       try:
-               return Task.Task.sig_implicit_deps(self)
-       except Utils.WafError:
-               return Constants.SIG_NIL
+    try:
+        return Task.Task.sig_implicit_deps(self)
+    except Utils.WafError:
+        return Constants.SIG_NIL
 
 for name in 'cc cxx'.split():
-       try:
-               cls = Task.TaskBase.classes[name]
-       except KeyError:
-               pass
-       else:
-               cls.post_run = post_run
-               cls.scan = scan
-               cls.sig_implicit_deps = sig_implicit_deps
+    try:
+        cls = Task.TaskBase.classes[name]
+    except KeyError:
+        pass
+    else:
+        cls.post_run = post_run
+        cls.scan = scan
+        cls.sig_implicit_deps = sig_implicit_deps
 
index ea277dc6554064b6f55834e1ad64faf0ef69583b..504e902c2a6546c3c9263499042a34fe597c04b2 100644 (file)
@@ -14,50 +14,50 @@ c_compiler['hpux'] = ['gcc', 'generic_cc']
 
 @conftest
 def find_generic_cc(conf):
-       v = conf.env
-       cc = None
-       if v['CC']: cc = v['CC']
-       elif 'CC' in conf.environ: cc = conf.environ['CC']
-       if not cc: cc = conf.find_program('cc', var='CC')
-       if not cc: conf.fatal('generic_cc was not found')
-       cc = conf.cmd_to_list(cc)
-       v['CC']  = cc
-       v['CC_NAME'] = 'generic'
+    v = conf.env
+    cc = None
+    if v['CC']: cc = v['CC']
+    elif 'CC' in conf.environ: cc = conf.environ['CC']
+    if not cc: cc = conf.find_program('cc', var='CC')
+    if not cc: conf.fatal('generic_cc was not found')
+    cc = conf.cmd_to_list(cc)
+    v['CC']  = cc
+    v['CC_NAME'] = 'generic'
 
 @conftest
 def generic_cc_common_flags(conf):
-       v = conf.env
+    v = conf.env
 
-       v['CC_SRC_F']            = ''
-       v['CC_TGT_F']            = ['-c', '-o', '']
-       v['CPPPATH_ST']          = '-I%s' # template for adding include paths
+    v['CC_SRC_F']            = ''
+    v['CC_TGT_F']            = ['-c', '-o', '']
+    v['CPPPATH_ST']          = '-I%s' # template for adding include paths
 
-       # linker
-       if not v['LINK_CC']: v['LINK_CC'] = v['CC']
-       v['CCLNK_SRC_F']         = ''
-       v['CCLNK_TGT_F']         = ['-o', '']
+    # linker
+    if not v['LINK_CC']: v['LINK_CC'] = v['CC']
+    v['CCLNK_SRC_F']         = ''
+    v['CCLNK_TGT_F']         = ['-o', '']
 
-       v['LIB_ST']              = '-l%s' # template for adding libs
-       v['LIBPATH_ST']          = '-L%s' # template for adding libpaths
-       v['STATICLIB_ST']        = '-l%s'
-       v['STATICLIBPATH_ST']    = '-L%s'
-       v['CCDEFINES_ST']        = '-D%s'
+    v['LIB_ST']              = '-l%s' # template for adding libs
+    v['LIBPATH_ST']          = '-L%s' # template for adding libpaths
+    v['STATICLIB_ST']        = '-l%s'
+    v['STATICLIBPATH_ST']    = '-L%s'
+    v['CCDEFINES_ST']        = '-D%s'
 
-#      v['SONAME_ST']           = '-Wl,-h -Wl,%s'
-#      v['SHLIB_MARKER']        = '-Bdynamic'
-#      v['STATICLIB_MARKER']    = '-Bstatic'
+#    v['SONAME_ST']           = '-Wl,-h -Wl,%s'
+#    v['SHLIB_MARKER']        = '-Bdynamic'
+#    v['STATICLIB_MARKER']    = '-Bstatic'
 
-       # program
-       v['program_PATTERN']     = '%s'
+    # program
+    v['program_PATTERN']     = '%s'
 
-       # shared library
-#      v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
-#      v['shlib_LINKFLAGS']     = ['-G']
-       v['shlib_PATTERN']       = 'lib%s.so'
+    # shared library
+#    v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
+#    v['shlib_LINKFLAGS']     = ['-G']
+    v['shlib_PATTERN']       = 'lib%s.so'
 
-       # static lib
-#      v['staticlib_LINKFLAGS'] = ['-Bstatic']
-#      v['staticlib_PATTERN']   = 'lib%s.a'
+    # static lib
+#    v['staticlib_LINKFLAGS'] = ['-Bstatic']
+#    v['staticlib_PATTERN']   = 'lib%s.a'
 
 detect = '''
 find_generic_cc
index 1461bf8c831592821a0ae4243093e4dde844dbb0..f3cb451fb0f73f206708ed50749cf450f30431b4 100644 (file)
@@ -13,57 +13,59 @@ c_compiler['irix'] = ['gcc', 'irixcc']
 
 @conftest
 def find_irixcc(conf):
-       v = conf.env
-       cc = None
-       if v['CC']: cc = v['CC']
-       elif 'CC' in conf.environ: cc = conf.environ['CC']
-       if not cc: cc = conf.find_program('cc', var='CC')
-       if not cc: conf.fatal('irixcc was not found')
-       cc = conf.cmd_to_list(cc)
-
-       try:
-               if Utils.cmd_output(cc + ['-version']) != '':
-                       conf.fatal('irixcc %r was not found' % cc)
-       except ValueError:
-               conf.fatal('irixcc -v could not be executed')
-
-       v['CC']  = cc
-       v['CC_NAME'] = 'irix'
+    v = conf.env
+    cc = None
+    if v['CC']: cc = v['CC']
+    elif 'CC' in conf.environ: cc = conf.environ['CC']
+    if not cc: cc = conf.find_program('cc', var='CC')
+    if not cc: conf.fatal('irixcc was not found')
+    cc = conf.cmd_to_list(cc)
+
+    try:
+        if Utils.cmd_output(cc + ['-c99'] + ['-version']) != '':
+            conf.fatal('irixcc %r was not found' % cc)
+    except ValueError:
+        conf.fatal('irixcc -v could not be executed')
+
+    conf.env.append_unique('CCFLAGS', '-c99')
+
+    v['CC']  = cc
+    v['CC_NAME'] = 'irix'
 
 @conftest
 def irixcc_common_flags(conf):
-       v = conf.env
-
-       v['CC_SRC_F']            = ''
-       v['CC_TGT_F']            = ['-c', '-o', '']
-       v['CPPPATH_ST']          = '-I%s' # template for adding include paths
-
-       # linker
-       if not v['LINK_CC']: v['LINK_CC'] = v['CC']
-       v['CCLNK_SRC_F']         = ''
-       v['CCLNK_TGT_F']         = ['-o', '']
-
-       v['LIB_ST']              = '-l%s' # template for adding libs
-       v['LIBPATH_ST']          = '-L%s' # template for adding libpaths
-       v['STATICLIB_ST']        = '-l%s'
-       v['STATICLIBPATH_ST']    = '-L%s'
-       v['CCDEFINES_ST']        = '-D%s'
-
-#      v['SONAME_ST']           = '-Wl,-h -Wl,%s'
-#      v['SHLIB_MARKER']        = '-Bdynamic'
-#      v['STATICLIB_MARKER']    = '-Bstatic'
-
-       # program
-       v['program_PATTERN']     = '%s'
-
-       # shared library
-#      v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
-#      v['shlib_LINKFLAGS']     = ['-G']
-       v['shlib_PATTERN']       = 'lib%s.so'
-
-       # static lib
-#      v['staticlib_LINKFLAGS'] = ['-Bstatic']
-#      v['staticlib_PATTERN']   = 'lib%s.a'
+    v = conf.env
+
+    v['CC_SRC_F']            = ''
+    v['CC_TGT_F']            = ['-c', '-o', '']
+    v['CPPPATH_ST']          = '-I%s' # template for adding include paths
+
+    # linker
+    if not v['LINK_CC']: v['LINK_CC'] = v['CC']
+    v['CCLNK_SRC_F']         = ''
+    v['CCLNK_TGT_F']         = ['-o', '']
+
+    v['LIB_ST']              = '-l%s' # template for adding libs
+    v['LIBPATH_ST']          = '-L%s' # template for adding libpaths
+    v['STATICLIB_ST']        = '-l%s'
+    v['STATICLIBPATH_ST']    = '-L%s'
+    v['CCDEFINES_ST']        = '-D%s'
+
+#    v['SONAME_ST']           = '-Wl,-h -Wl,%s'
+#    v['SHLIB_MARKER']        = '-Bdynamic'
+#    v['STATICLIB_MARKER']    = '-Bstatic'
+
+    # program
+    v['program_PATTERN']     = '%s'
+
+    # shared library
+#    v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
+#    v['shlib_LINKFLAGS']     = ['-G']
+    v['shlib_PATTERN']       = 'lib%s.so'
+
+    # static lib
+#    v['staticlib_LINKFLAGS'] = ['-Bstatic']
+#    v['staticlib_PATTERN']   = 'lib%s.a'
 
 detect = '''
 find_irixcc
index 9054a57af5b91fd0bc50c9ab986834f9dee1d915..075dcd326b78ea93588e1c0ac8f5dded6b634760 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # encoding: utf-8
 # Thomas Nagy, 2005-2008 (ita)
 
@@ -22,195 +21,197 @@ GAP = 15
 
 run_old = threading.Thread.run
 def run(*args, **kwargs):
-       try:
-               run_old(*args, **kwargs)
-       except (KeyboardInterrupt, SystemExit):
-               raise
-       except:
-               sys.excepthook(*sys.exc_info())
+    try:
+        run_old(*args, **kwargs)
+    except (KeyboardInterrupt, SystemExit):
+        raise
+    except:
+        sys.excepthook(*sys.exc_info())
 threading.Thread.run = run
 
 
 class TaskConsumer(object):
-       consumers = 1
+    consumers = 1
 
 def process(tsk):
-       m = tsk.master
-       if m.stop:
-               m.out.put(tsk)
-               return
-
-       try:
-               tsk.generator.bld.printout(tsk.display())
-               if tsk.__class__.stat: ret = tsk.__class__.stat(tsk)
-               # actual call to task's run() function
-               else: ret = tsk.call_run()
-       except Exception, e:
-               tsk.err_msg = Utils.ex_stack()
-               tsk.hasrun = EXCEPTION
-
-               # TODO cleanup
-               m.error_handler(tsk)
-               m.out.put(tsk)
-               return
-
-       if ret:
-               tsk.err_code = ret
-               tsk.hasrun = CRASHED
-       else:
-               try:
-                       tsk.post_run()
-               except Utils.WafError:
-                       pass
-               except Exception:
-                       tsk.err_msg = Utils.ex_stack()
-                       tsk.hasrun = EXCEPTION
-               else:
-                       tsk.hasrun = SUCCESS
-       if tsk.hasrun != SUCCESS:
-               m.error_handler(tsk)
-
-       m.out.put(tsk)
+    m = tsk.master
+    if m.stop:
+        m.out.put(tsk)
+        return
+
+    try:
+        tsk.generator.bld.printout(tsk.display())
+        if tsk.__class__.stat: ret = tsk.__class__.stat(tsk)
+        # actual call to task's run() function
+        else: ret = tsk.call_run()
+    except Exception, e:
+        tsk.err_msg = Utils.ex_stack()
+        tsk.hasrun = EXCEPTION
+
+        # TODO cleanup
+        m.error_handler(tsk)
+        m.out.put(tsk)
+        return
+
+    if ret:
+        tsk.err_code = ret
+        tsk.hasrun = CRASHED
+    else:
+        try:
+            tsk.post_run()
+        except Utils.WafError:
+            pass
+        except Exception:
+            tsk.err_msg = Utils.ex_stack()
+            tsk.hasrun = EXCEPTION
+        else:
+            tsk.hasrun = SUCCESS
+    if tsk.hasrun != SUCCESS:
+        m.error_handler(tsk)
+
+    m.out.put(tsk)
 
 class Parallel(object):
-       """
-       keep the consumer threads busy, and avoid consuming cpu cycles
-       when no more tasks can be added (end of the build, etc)
-       """
-       def __init__(self, bld, j=2):
-
-               # number of consumers
-               self.numjobs = j
-
-               self.manager = bld.task_manager
-               self.manager.current_group = 0
-
-               self.total = self.manager.total()
-
-               # tasks waiting to be processed - IMPORTANT
-               self.outstanding = []
-               self.maxjobs = MAXJOBS
-
-               # tasks that are awaiting for another task to complete
-               self.frozen = []
-
-               # tasks returned by the consumers
-               self.out = Queue(0)
-
-               self.count = 0 # tasks not in the producer area
-
-               self.processed = 1 # progress indicator
-
-               self.stop = False # error condition to stop the build
-               self.error = False # error flag
-
-       def get_next(self):
-               "override this method to schedule the tasks in a particular order"
-               if not self.outstanding:
-                       return None
-               return self.outstanding.pop(0)
-
-       def postpone(self, tsk):
-               "override this method to schedule the tasks in a particular order"
-               # TODO consider using a deque instead
-               if random.randint(0, 1):
-                       self.frozen.insert(0, tsk)
-               else:
-                       self.frozen.append(tsk)
-
-       def refill_task_list(self):
-               "called to set the next group of tasks"
-
-               while self.count > self.numjobs + GAP or self.count >= self.maxjobs:
-                       self.get_out()
-
-               while not self.outstanding:
-                       if self.count:
-                               self.get_out()
-
-                       if self.frozen:
-                               self.outstanding += self.frozen
-                               self.frozen = []
-                       elif not self.count:
-                               (jobs, tmp) = self.manager.get_next_set()
-                               if jobs != None: self.maxjobs = jobs
-                               if tmp: self.outstanding += tmp
-                               break
-
-       def get_out(self):
-               "the tasks that are put to execute are all collected using get_out"
-               ret = self.out.get()
-               self.manager.add_finished(ret)
-               if not self.stop and getattr(ret, 'more_tasks', None):
-                       self.outstanding += ret.more_tasks
-                       self.total += len(ret.more_tasks)
-               self.count -= 1
-
-       def error_handler(self, tsk):
-               "by default, errors make the build stop (not thread safe so be careful)"
-               if not Options.options.keep:
-                       self.stop = True
-               self.error = True
-
-       def start(self):
-               "execute the tasks"
-
-               while not self.stop:
-
-                       self.refill_task_list()
-
-                       # consider the next task
-                       tsk = self.get_next()
-                       if not tsk:
-                               if self.count:
-                                       # tasks may add new ones after they are run
-                                       continue
-                               else:
-                                       # no tasks to run, no tasks running, time to exit
-                                       break
-
-                       if tsk.hasrun:
-                               # if the task is marked as "run", just skip it
-                               self.processed += 1
-                               self.manager.add_finished(tsk)
-                               continue
-
-                       try:
-                               st = tsk.runnable_status()
-                       except Exception, e:
-                               self.processed += 1
-                               if self.stop and not Options.options.keep:
-                                       tsk.hasrun = SKIPPED
-                                       self.manager.add_finished(tsk)
-                                       continue
-                               self.error_handler(tsk)
-                               self.manager.add_finished(tsk)
-                               tsk.hasrun = EXCEPTION
-                               tsk.err_msg = Utils.ex_stack()
-                               continue
-
-                       if st == ASK_LATER:
-                               self.postpone(tsk)
-                       elif st == SKIP_ME:
-                               self.processed += 1
-                               tsk.hasrun = SKIPPED
-                               self.manager.add_finished(tsk)
-                       else:
-                               # run me: put the task in ready queue
-                               tsk.position = (self.processed, self.total)
-                               self.count += 1
-                               self.processed += 1
-                               tsk.master = self
-
-                               process(tsk)
-
-               # self.count represents the tasks that have been made available to the consumer threads
-               # collect all the tasks after an error else the message may be incomplete
-               while self.error and self.count:
-                       self.get_out()
-
-               #print loop
-               assert (self.count == 0 or self.stop)
+    """
+    keep the consumer threads busy, and avoid consuming cpu cycles
+    when no more tasks can be added (end of the build, etc)
+    """
+    def __init__(self, bld, j=2):
+
+        # number of consumers
+        self.numjobs = j
+
+        self.manager = bld.task_manager
+        self.manager.current_group = 0
+
+        self.total = self.manager.total()
+
+        # tasks waiting to be processed - IMPORTANT
+        self.outstanding = []
+        self.maxjobs = MAXJOBS
+
+        # tasks that are awaiting for another task to complete
+        self.frozen = []
+
+        # tasks returned by the consumers
+        self.out = Queue(0)
+
+        self.count = 0 # tasks not in the producer area
+
+        self.processed = 1 # progress indicator
+
+        self.stop = False # error condition to stop the build
+        self.error = False # error flag
+
+    def get_next(self):
+        "override this method to schedule the tasks in a particular order"
+        if not self.outstanding:
+            return None
+        return self.outstanding.pop(0)
+
+    def postpone(self, tsk):
+        "override this method to schedule the tasks in a particular order"
+        # TODO consider using a deque instead
+        if random.randint(0, 1):
+            self.frozen.insert(0, tsk)
+        else:
+            self.frozen.append(tsk)
+
+    def refill_task_list(self):
+        "called to set the next group of tasks"
+
+        while self.count > self.numjobs + GAP or self.count >= self.maxjobs:
+            self.get_out()
+
+        while not self.outstanding:
+            if self.count:
+                self.get_out()
+
+            if self.frozen:
+                self.outstanding += self.frozen
+                self.frozen = []
+            elif not self.count:
+                (jobs, tmp) = self.manager.get_next_set()
+                if jobs is not None:
+                    self.maxjobs = jobs
+                if tmp:
+                    self.outstanding += tmp
+                break
+
+    def get_out(self):
+        "the tasks that are put to execute are all collected using get_out"
+        ret = self.out.get()
+        self.manager.add_finished(ret)
+        if not self.stop and getattr(ret, 'more_tasks', None):
+            self.outstanding += ret.more_tasks
+            self.total += len(ret.more_tasks)
+        self.count -= 1
+
+    def error_handler(self, tsk):
+        "by default, errors make the build stop (not thread safe so be careful)"
+        if not Options.options.keep:
+            self.stop = True
+        self.error = True
+
+    def start(self):
+        "execute the tasks"
+
+        while not self.stop:
+
+            self.refill_task_list()
+
+            # consider the next task
+            tsk = self.get_next()
+            if not tsk:
+                if self.count:
+                    # tasks may add new ones after they are run
+                    continue
+                else:
+                    # no tasks to run, no tasks running, time to exit
+                    break
+
+            if tsk.hasrun:
+                # if the task is marked as "run", just skip it
+                self.processed += 1
+                self.manager.add_finished(tsk)
+                continue
+
+            try:
+                st = tsk.runnable_status()
+            except Exception, e:
+                self.processed += 1
+                if self.stop and not Options.options.keep:
+                    tsk.hasrun = SKIPPED
+                    self.manager.add_finished(tsk)
+                    continue
+                self.error_handler(tsk)
+                self.manager.add_finished(tsk)
+                tsk.hasrun = EXCEPTION
+                tsk.err_msg = Utils.ex_stack()
+                continue
+
+            if st == ASK_LATER:
+                self.postpone(tsk)
+            elif st == SKIP_ME:
+                self.processed += 1
+                tsk.hasrun = SKIPPED
+                self.manager.add_finished(tsk)
+            else:
+                # run me: put the task in ready queue
+                tsk.position = (self.processed, self.total)
+                self.count += 1
+                self.processed += 1
+                tsk.master = self
+
+                process(tsk)
+
+        # self.count represents the tasks that have been made available to the consumer threads
+        # collect all the tasks after an error else the message may be incomplete
+        while self.error and self.count:
+            self.get_out()
+
+        #print loop
+        assert (self.count == 0 or self.stop)
 
 
 # enable nothreads
index 1426029839719eede8830fe0377a4201273db1c4..476d8fc9e4576729f5f018bb7750112499d7c21f 100644 (file)
@@ -4,6 +4,7 @@
 import Options, Build, os
 from optparse import SUPPRESS_HELP
 from samba_utils import os_path_relpath, TO_LIST
+from samba_autoconf import library_flags
 
 def SAMBA3_ADD_OPTION(opt, option, help=(), dest=None, default=True,
                       with_name="with", without_name="without"):
@@ -46,33 +47,50 @@ Build.BuildContext.SAMBA3_IS_ENABLED_MODULE = SAMBA3_IS_ENABLED_MODULE
 
 def s3_fix_kwargs(bld, kwargs):
     '''fix the build arguments for s3 build rules to include the
-       necessary includes, subdir and cflags options '''
+    necessary includes, subdir and cflags options '''
     s3dir = os.path.join(bld.env.srcdir, 'source3')
     s3reldir = os_path_relpath(s3dir, bld.curdir)
 
     # the extra_includes list is relative to the source3 directory
     extra_includes = [ '.', 'include', 'lib', '../lib/tdb_compat' ]
+    # local heimdal paths only included when USING_SYSTEM_KRB5 is not set
     if not bld.CONFIG_SET("USING_SYSTEM_KRB5"):
         extra_includes += [ '../source4/heimdal/lib/com_err',
+                            '../source4/heimdal/lib/krb5',
                             '../source4/heimdal/lib/gssapi',
-                            '../source4/heimdal_build' ]
+                            '../source4/heimdal_build',
+                            '../bin/default/source4/heimdal/lib/asn1' ]
 
-    if bld.CONFIG_SET('BUILD_TDB2'):
-        if not bld.CONFIG_SET('USING_SYSTEM_TDB2'):
-            extra_includes += [ '../lib/tdb2' ]
+    if bld.CONFIG_SET('USING_SYSTEM_TDB'):
+        (tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb')
+        extra_includes += tdb_cpppath
     else:
-        if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
-            extra_includes += [ '../lib/tdb/include' ]
+        extra_includes += [ '../lib/tdb/include' ]
 
-    if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
+    if bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
+        (tevent_includes, tevent_ldflags, tevent_cpppath) = library_flags(bld, 'tevent')
+        extra_includes += tevent_cpppath
+    else:
         extra_includes += [ '../lib/tevent' ]
 
-    if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
+    if bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
+        (talloc_includes, talloc_ldflags, talloc_cpppath) = library_flags(bld, 'talloc')
+        extra_includes += talloc_cpppath
+    else:
         extra_includes += [ '../lib/talloc' ]
 
-    if not bld.CONFIG_SET('USING_SYSTEM_POPT'):
+    if bld.CONFIG_SET('USING_SYSTEM_POPT'):
+        (popt_includes, popt_ldflags, popt_cpppath) = library_flags(bld, 'popt')
+        extra_includes += popt_cpppath
+    else:
         extra_includes += [ '../lib/popt' ]
 
+    if bld.CONFIG_SET('USING_SYSTEM_INIPARSER'):
+        (iniparser_includes, iniparser_ldflags, iniparser_cpppath) = library_flags(bld, 'iniparser')
+        extra_includes += iniparser_cpppath
+    else:
+        extra_includes += [ '../lib/iniparser' ]
+
     # s3 builds assume that they will have a bunch of extra include paths
     includes = []
     for d in extra_includes:
@@ -83,32 +101,26 @@ def s3_fix_kwargs(bld, kwargs):
         includes += TO_LIST(kwargs['includes'])
     kwargs['includes'] = includes
 
-    # some S3 code assumes that CONFIGFILE is set
-    cflags = ['-DCONFIGFILE="%s"' % bld.env['CONFIGFILE']]
-    if 'cflags' in kwargs:
-        cflags += TO_LIST(kwargs['cflags'])
-    kwargs['cflags'] = cflags
-
 # these wrappers allow for mixing of S3 and S4 build rules in the one build
 
 def SAMBA3_LIBRARY(bld, name, *args, **kwargs):
-       s3_fix_kwargs(bld, kwargs)
-       return bld.SAMBA_LIBRARY(name, *args, **kwargs)
+    s3_fix_kwargs(bld, kwargs)
+    return bld.SAMBA_LIBRARY(name, *args, **kwargs)
 Build.BuildContext.SAMBA3_LIBRARY = SAMBA3_LIBRARY
 
 def SAMBA3_MODULE(bld, name, *args, **kwargs):
-       s3_fix_kwargs(bld, kwargs)
-       return bld.SAMBA_MODULE(name, *args, **kwargs)
+    s3_fix_kwargs(bld, kwargs)
+    return bld.SAMBA_MODULE(name, *args, **kwargs)
 Build.BuildContext.SAMBA3_MODULE = SAMBA3_MODULE
 
 def SAMBA3_SUBSYSTEM(bld, name, *args, **kwargs):
-       s3_fix_kwargs(bld, kwargs)
-       return bld.SAMBA_SUBSYSTEM(name, *args, **kwargs)
+    s3_fix_kwargs(bld, kwargs)
+    return bld.SAMBA_SUBSYSTEM(name, *args, **kwargs)
 Build.BuildContext.SAMBA3_SUBSYSTEM = SAMBA3_SUBSYSTEM
 
 def SAMBA3_BINARY(bld, name, *args, **kwargs):
-       s3_fix_kwargs(bld, kwargs)
-       return bld.SAMBA_BINARY(name, *args, **kwargs)
+    s3_fix_kwargs(bld, kwargs)
+    return bld.SAMBA_BINARY(name, *args, **kwargs)
 Build.BuildContext.SAMBA3_BINARY = SAMBA3_BINARY
 
 def SAMBA3_PYTHON(bld, name, *args, **kwargs):
index 990e1e5fdfe923bf25608320f053ee3f0e6e4266..ed977ba4c2b3e156dfafc5ba6325cf148e401e4e 100644 (file)
@@ -15,9 +15,11 @@ version_key = lambda x: map(int, x.split("."))
 def normalise_signature(sig):
     '''normalise a signature from gdb'''
     sig = sig.strip()
-    sig = re.sub('^\$[0-9]+\s=\s\{*', '', sig)
-    sig = re.sub('\}(\s0x[0-9a-f]+\s<\w+>)?$', '', sig)
+    sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}$', r'\1', sig)
+    sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}(\s0x[0-9a-f]+\s<\w+>)+$', r'\1', sig)
+    sig = re.sub('^\$[0-9]+\s=\s(0x[0-9a-f]+)\s?(<\w+>)?$', r'\1', sig)
     sig = re.sub('0x[0-9a-f]+', '0xXXXX', sig)
+    sig = re.sub('", <incomplete sequence (\\\\[a-z0-9]+)>', r'\1"', sig)
 
     for t in abi_type_maps:
         # we need to cope with non-word characters in mapped types
@@ -30,11 +32,13 @@ def normalise_signature(sig):
         sig = re.sub(m, abi_type_maps[t], sig)
     return sig
 
+
 def normalise_varargs(sig):
     '''cope with older versions of gdb'''
     sig = re.sub(',\s\.\.\.', '', sig)
     return sig
 
+
 def parse_sigs(sigs, abi_match):
     '''parse ABI signatures file'''
     abi_match = samba_utils.TO_LIST(abi_match)
@@ -54,6 +58,7 @@ def parse_sigs(sigs, abi_match):
                     break
             if not matched:
                 continue
+        Logs.debug("%s -> %s" % (sa[1], normalise_signature(sa[1])))
         ret[sa[0]] = normalise_signature(sa[1])
     return ret
 
@@ -105,7 +110,7 @@ def abi_check_task(self):
             got_error = True
 
     if got_error:
-        raise Utils.WafError('ABI for %s has changed - please fix library version then build with --abi-update\nSee http://wiki.samba.org/index.php/Waf#ABI_Checking for more information' % libname)
+        raise Utils.WafError('ABI for %s has changed - please fix library version then build with --abi-update\nSee http://wiki.samba.org/index.php/Waf#ABI_Checking for more information\nIf you have not changed any ABI, and your platform always gives this error, please configure with --abi-check-disable to skip this check' % libname)
 
 
 t = Task.task_type_from_func('abi_check', abi_check_task, color='BLUE', ext_in='.bin')
@@ -149,7 +154,7 @@ def abi_process_file(fname, version, symmap):
 
 def abi_write_vscript(vscript, libname, current_version, versions, symmap, abi_match):
     '''write a vscript file for a library in --version-script format
-    
+
     :param vscript: Path to the vscript file
     :param libname: Name of the library, uppercased
     :param current_version: Current version
@@ -177,10 +182,19 @@ def abi_write_vscript(vscript, libname, current_version, versions, symmap, abi_m
         f.write("}%s;\n\n" % last_key)
         last_key = " %s" % symver
     f.write("%s {\n" % current_version)
+    local_abi = filter(lambda x: x[0] == '!', abi_match)
+    global_abi = filter(lambda x: x[0] != '!', abi_match)
     f.write("\tglobal:\n")
-    for x in abi_match:
-        f.write("\t\t%s;\n" % x)
-    if abi_match != ["*"]:
+    if len(global_abi) > 0:
+        for x in global_abi:
+            f.write("\t\t%s;\n" % x)
+    else:
+        f.write("\t\t*;\n")
+    if len(local_abi) > 0:
+        f.write("\tlocal:\n")
+        for x in local_abi:
+            f.write("\t\t%s;\n" % x[1:])
+    elif abi_match != ["*"]:
         f.write("\tlocal: *;\n")
     f.write("};\n")
     f.close()
index 6ed719a80adde3c2984742ac94943a56b0d1e751..5d3cc5a6882dd57202b9dc38b9a0f2709aebdf2e 100644 (file)
@@ -62,9 +62,9 @@ def COMPOUND_END(conf, result):
     conf.check_message_1 = conf.saved_check_message_1
     conf.check_message_2 = conf.saved_check_message_2
     p = conf.check_message_2
-    if result == True:
+    if result:
         p('ok ')
-    elif result == False:
+    elif not result:
         p('not found', 'YELLOW')
     else:
         p(result)
@@ -92,13 +92,17 @@ def CHECK_HEADER(conf, h, add_headers=False, lib=None):
                 conf.env.hlist.append(h)
         return True
 
-    (ccflags, ldflags) = library_flags(conf, lib)
+    (ccflags, ldflags, cpppath) = library_flags(conf, lib)
 
     hdrs = hlist_to_string(conf, headers=h)
+    if lib is None:
+        lib = ""
     ret = conf.check(fragment='%s\nint main(void) { return 0; }' % hdrs,
                      type='nolink',
                      execute=0,
                      ccflags=ccflags,
+                     includes=cpppath,
+                     uselib=lib.upper(),
                      msg="Checking for header %s" % h)
     if not ret:
         missing_headers.add(h)
@@ -237,7 +241,7 @@ def CHECK_FUNC(conf, f, link=True, lib=None, headers=None):
 
     conf.COMPOUND_START('Checking for %s' % f)
 
-    if link is None or link == True:
+    if link is None or link:
         ret = CHECK_CODE(conf,
                          # this is based on the autoconf strategy
                          '''
@@ -280,7 +284,7 @@ def CHECK_FUNC(conf, f, link=True, lib=None, headers=None):
                              headers=headers,
                              msg='Checking for macro %s' % f)
 
-    if not ret and (link is None or link == False):
+    if not ret and (link is None or not link):
         ret = CHECK_VARIABLE(conf, f,
                              define=define,
                              headers=headers,
@@ -368,7 +372,12 @@ def CHECK_CODE(conf, code, define,
 
     uselib = TO_LIST(lib)
 
-    (ccflags, ldflags) = library_flags(conf, uselib)
+    (ccflags, ldflags, cpppath) = library_flags(conf, uselib)
+
+    includes = TO_LIST(includes)
+    includes.extend(cpppath)
+
+    uselib = [l.upper() for l in uselib]
 
     cflags.extend(ccflags)
 
@@ -428,10 +437,10 @@ def CHECK_STRUCTURE_MEMBER(conf, structname, member,
 
 
 @conf
-def CHECK_CFLAGS(conf, cflags):
+def CHECK_CFLAGS(conf, cflags, fragment='int main(void) { return 0; }\n'):
     '''check if the given cflags are accepted by the compiler
     '''
-    return conf.check(fragment='int main(void) { return 0; }\n',
+    return conf.check(fragment=fragment,
                       execute=0,
                       type='nolink',
                       ccflags=cflags,
@@ -458,7 +467,16 @@ def CONFIG_GET(conf, option):
 @conf
 def CONFIG_SET(conf, option):
     '''return True if a configuration option was found'''
-    return (option in conf.env) and (conf.env[option] != ())
+    if option not in conf.env:
+        return False
+    v = conf.env[option]
+    if v is None:
+        return False
+    if v == []:
+        return False
+    if v == ():
+        return False
+    return True
 Build.BuildContext.CONFIG_SET = CONFIG_SET
 Build.BuildContext.CONFIG_GET = CONFIG_GET
 
@@ -467,23 +485,24 @@ def library_flags(self, libs):
     '''work out flags from pkg_config'''
     ccflags = []
     ldflags = []
+    cpppath = []
     for lib in TO_LIST(libs):
-        inc_path = getattr(self.env, 'CPPPATH_%s' % lib.upper(), [])
-        lib_path = getattr(self.env, 'LIBPATH_%s' % lib.upper(), [])
-        ccflags.extend(['-I%s' % i for i in inc_path])
-        # note that we do not add the -L in here, as that is added by the waf
+        # note that we do not add the -I and -L in here, as that is added by the waf
         # core. Adding it here would just change the order that it is put on the link line
         # which can cause system paths to be added before internal libraries
         extra_ccflags = TO_LIST(getattr(self.env, 'CCFLAGS_%s' % lib.upper(), []))
         extra_ldflags = TO_LIST(getattr(self.env, 'LDFLAGS_%s' % lib.upper(), []))
+        extra_cpppath = TO_LIST(getattr(self.env, 'CPPPATH_%s' % lib.upper(), []))
         ccflags.extend(extra_ccflags)
         ldflags.extend(extra_ldflags)
+        cpppath.extend(extra_cpppath)
     if 'EXTRA_LDFLAGS' in self.env:
         ldflags.extend(self.env['EXTRA_LDFLAGS'])
 
     ccflags = unique_list(ccflags)
     ldflags = unique_list(ldflags)
-    return (ccflags, ldflags)
+    cpppath = unique_list(cpppath)
+    return (ccflags, ldflags, cpppath)
 
 
 @conf
@@ -507,11 +526,11 @@ int foo()
             ret.append(lib)
             continue
 
-        (ccflags, ldflags) = library_flags(conf, lib)
+        (ccflags, ldflags, cpppath) = library_flags(conf, lib)
         if shlib:
-            res = conf.check(features='cc cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags)
+            res = conf.check(features='cc cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
         else:
-            res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags)
+            res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
 
         if not res:
             if mandatory:
@@ -597,13 +616,32 @@ def SAMBA_CONFIG_H(conf, path=None):
     if not IN_LAUNCH_DIR(conf):
         return
 
+    if Options.options.debug:
+        conf.ADD_CFLAGS('-g',
+                        testflags=True)
+
     if Options.options.developer:
         # we add these here to ensure that -Wstrict-prototypes is not set during configure
-        conf.ADD_CFLAGS('-Wall -g -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k -Wmissing-prototypes -fno-common',
+        conf.ADD_CFLAGS('-Wall -g -Wshadow -Werror=strict-prototypes -Wstrict-prototypes -Werror=pointer-arith -Wpointer-arith -Wcast-align -Werror=write-strings -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k -Wmissing-prototypes -fno-common -Werror=address',
                         testflags=True)
         conf.ADD_CFLAGS('-Wcast-qual', testflags=True)
         conf.env.DEVELOPER_MODE = True
 
+        # This check is because for ldb_search(), a NULL format string
+        # is not an error, but some compilers complain about that.
+        if CHECK_CFLAGS(conf, ["-Werror=format", "-Wformat=2"], '''
+int testformat(char *format, ...) __attribute__ ((format (__printf__, 1, 2)));
+
+int main(void) {
+        testformat(0);
+        return 0;
+}
+
+'''):
+            if not 'EXTRA_CFLAGS' in conf.env:
+                conf.env['EXTRA_CFLAGS'] = []
+            conf.env['EXTRA_CFLAGS'].extend(TO_LIST("-Werror=format"))
+
     if Options.options.picky_developer:
         conf.ADD_CFLAGS('-Werror', testflags=True)
 
@@ -720,9 +758,9 @@ def SETUP_CONFIGURE_CACHE(conf, enable):
 def SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS(conf):
     # we don't want any libraries or modules to rely on runtime
     # resolution of symbols
-    if sys.platform != "openbsd4":
+    if sys.platform != "openbsd4" and sys.platform != "openbsd5":
         conf.env.undefined_ldflags = conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
 
-    if sys.platform != "openbsd4" and conf.env.undefined_ignore_ldflags == []:
+    if sys.platform != "openbsd4" and sys.platform != "openbsd5" and conf.env.undefined_ignore_ldflags == []:
         if conf.CHECK_LDFLAGS(['-undefined', 'dynamic_lookup']):
             conf.env.undefined_ignore_ldflags = ['-undefined', 'dynamic_lookup']
index a29bfa3a1bd2fe142c9ab9bf4af53aeaab1a539f..b8a4101dca43d87437c85e037e1ec3e6768ea3e5 100644 (file)
@@ -78,17 +78,22 @@ def LIB_MAY_BE_BUNDLED(conf, libname):
 
 @conf
 def LIB_MUST_BE_BUNDLED(conf, libname):
-    return ('ALL' in conf.env.BUNDLED_LIBS or 
+    return ('ALL' in conf.env.BUNDLED_LIBS or
             libname in conf.env.BUNDLED_LIBS)
 
+@conf
+def LIB_MUST_BE_PRIVATE(conf, libname):
+    return ('ALL' in conf.env.PRIVATE_LIBS or
+            libname in conf.env.PRIVATE_LIBS)
 
 @conf
 def CHECK_PREREQUISITES(conf, prereqs):
+    missing = []
     for syslib in TO_LIST(prereqs):
         f = 'FOUND_SYSTEMLIB_%s' % syslib
         if not f in conf.env:
-            return False
-    return True
+            missing.append(syslib)
+    return missing
 
 
 @runonce
@@ -109,9 +114,10 @@ def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0',
     # system version is found. That prevents possible use of mixed library
     # versions
     if onlyif:
-        if not conf.CHECK_PREREQUISITES(onlyif):
+        missing = conf.CHECK_PREREQUISITES(onlyif)
+        if missing:
             if not conf.LIB_MAY_BE_BUNDLED(libname):
-                Logs.error('ERROR: Use of system library %s depends on missing system library %s' % (libname, onlyif))
+                Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing))
                 sys.exit(1)
             conf.env[found] = False
             return False
@@ -169,9 +175,10 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
     # system version is found. That prevents possible use of mixed library
     # versions
     if onlyif:
-        if not conf.CHECK_PREREQUISITES(onlyif):
+        missing = conf.CHECK_PREREQUISITES(onlyif)
+        if missing:
             if not conf.LIB_MAY_BE_BUNDLED(libname):
-                Logs.error('ERROR: Use of system library %s depends on missing system library %s' % (libname, syslib))
+                Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing))
                 sys.exit(1)
             conf.env[found] = False
             return False
@@ -206,6 +213,9 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
     return False
 
 
+def tuplize_version(version):
+    return tuple([int(x) for x in version.split(".")])
+
 @runonce
 @conf
 def CHECK_BUNDLED_SYSTEM_PYTHON(conf, libname, modulename, minversion='0.0.0'):
@@ -230,7 +240,7 @@ def CHECK_BUNDLED_SYSTEM_PYTHON(conf, libname, modulename, minversion='0.0.0'):
         except AttributeError:
             found = False
         else:
-            found = tuple(version.split(".")) >= tuple(minversion.split("."))
+            found = tuplize_version(version) >= tuplize_version(minversion)
     if not found and not conf.LIB_MAY_BE_BUNDLED(libname):
         Logs.error('ERROR: Python module %s of version %s not found, and bundling disabled' % (libname, minversion))
         sys.exit(1)
index c7e596d27aad48ec793a06ecf0ed6e5caed951a2..0274f665a68d8a8e38423908fe15ade1ff0c9b0e 100644 (file)
@@ -1,10 +1,75 @@
 # a set of config tests that use the samba_autoconf functions
 # to test for commonly needed configuration options
 
-import os, Build, shutil, Utils, re
+import os, shutil, re
+import Build, Configure, Utils
 from Configure import conf
 from samba_utils import *
 
+
+def add_option(self, *k, **kw):
+    '''syntax help: provide the "match" attribute to opt.add_option() so that folders can be added to specific config tests'''
+    match = kw.get('match', [])
+    if match:
+        del kw['match']
+    opt = self.parser.add_option(*k, **kw)
+    opt.match = match
+    return opt
+Options.Handler.add_option = add_option
+
+@conf
+def check(self, *k, **kw):
+    '''Override the waf defaults to inject --with-directory options'''
+
+    if not 'env' in kw:
+        kw['env'] = self.env.copy()
+
+    # match the configuration test with speficic options, for example:
+    # --with-libiconv -> Options.options.iconv_open -> "Checking for library iconv"
+    additional_dirs = []
+    if 'msg' in kw:
+        msg = kw['msg']
+        for x in Options.Handler.parser.parser.option_list:
+             if getattr(x, 'match', None) and msg in x.match:
+                 d = getattr(Options.options, x.dest, '')
+                 if d:
+                     additional_dirs.append(d)
+
+    # we add the additional dirs twice: once for the test data, and again if the compilation test suceeds below
+    def add_options_dir(dirs, env):
+        for x in dirs:
+             if not x in env.CPPPATH:
+                 env.CPPPATH = [os.path.join(x, 'include')] + env.CPPPATH
+             if not x in env.LIBPATH:
+                 env.LIBPATH = [os.path.join(x, 'lib')] + env.LIBPATH
+
+    add_options_dir(additional_dirs, kw['env'])
+
+    self.validate_c(kw)
+    self.check_message_1(kw['msg'])
+    ret = None
+    try:
+        ret = self.run_c_code(*k, **kw)
+    except Configure.ConfigurationError, e:
+        self.check_message_2(kw['errmsg'], 'YELLOW')
+        if 'mandatory' in kw and kw['mandatory']:
+            if Logs.verbose > 1:
+                raise
+            else:
+                self.fatal('the configuration failed (see %r)' % self.log.name)
+    else:
+        kw['success'] = ret
+        self.check_message_2(self.ret_msg(kw['okmsg'], kw))
+
+        # success! keep the CPPPATH/LIBPATH
+        add_options_dir(additional_dirs, self.env)
+
+    self.post_check(*k, **kw)
+    if not kw.get('execute', False):
+        return ret == 0
+    return ret
+
+
 @conf
 def CHECK_ICONV(conf, define='HAVE_NATIVE_ICONV'):
     '''check if the iconv library is installed
@@ -18,11 +83,29 @@ def CHECK_ICONV(conf, define='HAVE_NATIVE_ICONV'):
 @conf
 def CHECK_LARGEFILE(conf, define='HAVE_LARGEFILE'):
     '''see what we need for largefile support'''
+    getconf_cflags = conf.CHECK_COMMAND(['getconf', 'LFS_CFLAGS']);
+    if getconf_cflags is not False:
+        if (conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
+                            define='WORKING_GETCONF_LFS_CFLAGS',
+                            execute=True,
+                            cflags=getconf_cflags,
+                            msg='Checking getconf large file support flags work')):
+            conf.ADD_CFLAGS(getconf_cflags)
+            getconf_cflags_list=TO_LIST(getconf_cflags)
+            for flag in getconf_cflags_list:
+                if flag[:2] == "-D":
+                    flag_split = flag[2:].split('=')
+                    if len(flag_split) == 1:
+                        conf.DEFINE(flag_split[0], '1')
+                    else:
+                        conf.DEFINE(flag_split[0], flag_split[1])
+
     if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
                        define,
                        execute=True,
-                       msg='Checking for large file support'):
+                       msg='Checking for large file support without additional flags'):
         return True
+
     if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
                        define,
                        execute=True,
@@ -30,6 +113,14 @@ def CHECK_LARGEFILE(conf, define='HAVE_LARGEFILE'):
                        msg='Checking for -D_FILE_OFFSET_BITS=64'):
         conf.DEFINE('_FILE_OFFSET_BITS', 64)
         return True
+
+    if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
+                       define,
+                       execute=True,
+                       cflags='-D_LARGE_FILES',
+                       msg='Checking for -D_LARGE_FILES'):
+        conf.DEFINE('_LARGE_FILES', 1)
+        return True
     return False
 
 
@@ -295,7 +386,7 @@ def CHECK_PERL_MANPAGE(conf, msg=None, section=None):
     dest.write("""
 use ExtUtils::MakeMaker;
 WriteMakefile(
-    'NAME'     => 'WafTest',
+    'NAME'    => 'WafTest',
     'EXE_FILES' => [ 'WafTest' ]
 );
 """)
index 0bd2c6cf67bb6e75870343dd13558318e2ea060c..3220f3537d07f446f2db74dc3f53a08d12067e57 100644 (file)
@@ -80,7 +80,7 @@ def build_dependencies(self):
         # extra link flags from pkg_config
         libs = self.final_syslibs.copy()
 
-        (ccflags, ldflags) = library_flags(self, list(libs))
+        (ccflags, ldflags, cpppath) = library_flags(self, list(libs))
         new_ldflags        = getattr(self, 'samba_ldflags', [])[:]
         new_ldflags.extend(ldflags)
         self.ldflags       = new_ldflags
@@ -136,7 +136,7 @@ def build_includes(self):
     includes = []
 
     # maybe add local includes
-    if getattr(self, 'local_include', True) == True and getattr(self, 'local_include_first', True):
+    if getattr(self, 'local_include', True) and getattr(self, 'local_include_first', True):
         includes.append('.')
 
     includes.extend(self.samba_includes_extended)
@@ -153,7 +153,7 @@ def build_includes(self):
         t = bld.name_to_obj(d, bld.env)
         bld.ASSERT(t is not None, "Unable to find dependency %s for %s" % (d, self.sname))
         inclist = getattr(t, 'samba_includes_extended', [])[:]
-        if getattr(t, 'local_include', True) == True:
+        if getattr(t, 'local_include', True):
             inclist.append('.')
         if inclist == []:
             continue
@@ -169,7 +169,7 @@ def build_includes(self):
         relpath = os_path_relpath(inc, mypath)
         includes.append(relpath)
 
-    if getattr(self, 'local_include', True) == True and not getattr(self, 'local_include_first', True):
+    if getattr(self, 'local_include', True) and not getattr(self, 'local_include_first', True):
         includes.append('.')
 
     # now transform the includes list to be relative to the top directory
@@ -190,8 +190,6 @@ def build_includes(self):
           self.sname, self.includes)
 
 
-
-
 def add_init_functions(self):
     '''This builds the right set of init functions'''
 
@@ -216,7 +214,7 @@ def add_init_functions(self):
     if m is not None:
         modules.append(m)
 
-    sentinal = getattr(self, 'init_function_sentinal', 'NULL')
+    sentinel = getattr(self, 'init_function_sentinel', 'NULL')
 
     targets    = LOCAL_CACHE(bld, 'TARGET_TYPE')
     cflags = getattr(self, 'samba_cflags', [])[:]
@@ -224,8 +222,8 @@ def add_init_functions(self):
     if modules == []:
         sname = sname.replace('-','_')
         sname = sname.replace('/','_')
-        cflags.append('-DSTATIC_%s_MODULES=%s' % (sname, sentinal))
-        if sentinal == 'NULL':
+        cflags.append('-DSTATIC_%s_MODULES=%s' % (sname, sentinel))
+        if sentinel == 'NULL':
             cflags.append('-DSTATIC_%s_MODULES_PROTO' % sname)
         self.ccflags = cflags
         return
@@ -238,11 +236,11 @@ def add_init_functions(self):
             if targets[d['TARGET']] != 'DISABLED':
                 init_fn_list.append(d['INIT_FUNCTION'])
         if init_fn_list == []:
-            cflags.append('-DSTATIC_%s_MODULES=%s' % (m, sentinal))
-            if sentinal == 'NULL':
+            cflags.append('-DSTATIC_%s_MODULES=%s' % (m, sentinel))
+            if sentinel == 'NULL':
                 cflags.append('-DSTATIC_%s_MODULES_PROTO' % m)
         else:
-            cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentinal))
+            cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentinel))
             proto=''
             for f in init_fn_list:
                 proto = proto + '_MODULE_PROTO(%s)' % f
@@ -250,7 +248,6 @@ def add_init_functions(self):
     self.ccflags = cflags
 
 
-
 def check_duplicate_sources(bld, tgt_list):
     '''see if we are compiling the same source file more than once
        without an allow_duplicates attribute'''
@@ -297,11 +294,11 @@ def check_duplicate_sources(bld, tgt_list):
         for tname in subsystems[s]:
             if len(subsystems[s][tname]) > 1:
                 raise Utils.WafError("ERROR: source %s is in more than one subsystem of target '%s': %s" % (s, tname, subsystems[s][tname]))
-                
+
     return ret
 
 
-def check_orpaned_targets(bld, tgt_list):
+def check_orphaned_targets(bld, tgt_list):
     '''check if any build targets are orphaned'''
 
     target_dict = LOCAL_CACHE(bld, 'TARGET_TYPE')
@@ -309,7 +306,7 @@ def check_orpaned_targets(bld, tgt_list):
     debug('deps: checking for orphaned targets')
 
     for t in tgt_list:
-        if getattr(t, 'samba_used', False) == True:
+        if getattr(t, 'samba_used', False):
             continue
         type = target_dict[t.sname]
         if not type in ['BINARY', 'LIBRARY', 'MODULE', 'ET', 'PYTHON']:
@@ -1148,7 +1145,7 @@ def check_project_rules(bld):
 
     debug('deps: project rules stage1 completed')
 
-    #check_orpaned_targets(bld, tgt_list)
+    #check_orphaned_targets(bld, tgt_list)
 
     if not check_duplicate_sources(bld, tgt_list):
         Logs.error("Duplicate sources present - aborting")
index a11a37cc1bf7595bddc531587aeebc38b3bd6cf9..fae2759dac0d6d6646c5c81117b591d943f3f8ed 100644 (file)
@@ -5,6 +5,7 @@ import Utils, os, sys, tarfile, stat, Scripting, Logs, Options
 from samba_utils import *
 
 dist_dirs = None
+dist_files = None
 dist_blacklist = ""
 
 def add_symlink(tar, fname, abspath, basedir):
@@ -97,7 +98,43 @@ def vcs_dir_contents(path):
     return Utils.cmd_output(ls_files_cmd, cwd=cwd, env=env).split()
 
 
-def dist(appname='',version=''):
+def dist(appname='', version=''):
+
+    def add_files_to_tarball(tar, srcdir, srcsubdir, dstdir, dstsubdir, blacklist, files):
+        if blacklist is None:
+            blacklist = []
+        for f in files:
+            abspath = os.path.join(srcdir, f)
+
+            if srcsubdir != '.':
+                f = f[len(srcsubdir)+1:]
+
+            # Remove files in the blacklist
+            if f in blacklist:
+                continue
+            blacklisted = False
+            # Remove directories in the blacklist
+            for d in blacklist:
+                if f.startswith(d):
+                    blacklisted = True
+            if blacklisted:
+                continue
+            if os.path.isdir(abspath):
+                continue
+            if dstsubdir != '.':
+                f = dstsubdir + '/' + f
+            fname = dstdir + '/' + f
+            add_tarfile(tar, fname, abspath, srcsubdir)
+
+
+    def list_directory_files(abspath):
+        out_files = []
+        for root, dirs, files in os.walk(abspath):
+            for f in files:
+                out_files.append(os.path.join(root, f))
+        return out_files
+
+
     if not isinstance(appname, str) or not appname:
         # this copes with a mismatch in the calling arguments for dist()
         appname = Utils.g_module.APPNAME
@@ -134,28 +171,26 @@ def dist(appname='',version=''):
         except Exception, e:
             Logs.error('unable to get contents of %s: %s' % (absdir, e))
             sys.exit(1)
-        for f in files:
-            abspath = os.path.join(srcdir, f)
+        add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, files)
 
-            if dir != '.':
-                f = f[len(dir)+1:]
+    if dist_files:
+        for file in dist_files.split():
+            if file.find(':') != -1:
+                destfile = file.split(':')[1]
+                file = file.split(':')[0]
+            else:
+                destfile = file
 
-            # Remove files in the blacklist
-            if f in dist_blacklist:
-                continue
-            blacklisted = False
-            # Remove directories in the blacklist
-            for d in blacklist:
-                if f.startswith(d):
-                    blacklisted = True
-            if blacklisted:
-                continue
-            if os.path.isdir(abspath):
-                continue
-            if destdir != '.':
-                f = destdir + '/' + f
-            fname = dist_base + '/' + f
-            add_tarfile(tar, fname, abspath, dir)
+            absfile = os.path.join(srcdir, file)
+
+            if os.path.isdir(absfile):
+                destdir = destfile
+                dir = file
+                files = list_directory_files(dir)
+                add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, files)
+            else:
+                fname = dist_base + '/' + destfile
+                add_tarfile(tar, fname, absfile, destfile)
 
     tar.close()
 
@@ -194,6 +229,15 @@ def DIST_DIRS(dirs):
     if not dist_dirs:
         dist_dirs = dirs
 
+@conf
+def DIST_FILES(files, extend=False):
+    '''set additional files for packaging, relative to top srcdir'''
+    global dist_files
+    if not dist_files:
+        dist_files = files
+    elif extend:
+        dist_files = dist_files + " " + files
+
 @conf
 def DIST_BLACKLIST(blacklist):
     '''set the files to exclude from packaging, relative to top srcdir'''
index cca6420b6cdebc11fd805ab7737a7b5ba6642800..50ccad743d46d9e624d6fbfdc9832c02f374b5e2 100644 (file)
@@ -119,7 +119,6 @@ def public_headers_simple(bld, public_headers, header_path=None, public_headers_
             h_name =  h
             inst_name = os.path.basename(h)
         bld.INSTALL_FILES('${INCLUDEDIR}', h_name, destname=inst_name)
-        
 
 
 def PUBLIC_HEADERS(bld, public_headers, header_path=None, public_headers_install=True):
index 26d0a371e6d929bd21cdb74fbf8eade22f02e6b0..5e53989c04fbefae21005d4069c6b86cad51974a 100644 (file)
@@ -134,7 +134,8 @@ def install_library(self):
 
     # tell waf to install the library
     bld.install_as(os.path.join(install_path, install_name),
-                   os.path.join(self.path.abspath(bld.env), inst_name))
+                   os.path.join(self.path.abspath(bld.env), inst_name),
+                   chmod=MODE_755)
     if install_link and install_link != install_name:
         # and the symlink if needed
         bld.symlink_as(os.path.join(install_path, install_link), os.path.basename(install_name))
index 951fd4c1f6194ae5f80bc779f1cb2e4a7e9cd3f4..f0f430d2bfdb6f35d334e34961d9b29b2dfd7d33 100644 (file)
@@ -12,50 +12,50 @@ import preproc, Task
 @feature('cc', 'cxx')
 @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
 def apply_incpaths(self):
-       lst = []
-
-       try:
-               kak = self.bld.kak
-       except AttributeError:
-               kak = self.bld.kak = {}
-
-       # TODO move the uselib processing out of here
-       for lib in self.to_list(self.uselib):
-               for path in self.env['CPPPATH_' + lib]:
-                       if not path in lst:
-                               lst.append(path)
-       if preproc.go_absolute:
-               for path in preproc.standard_includes:
-                       if not path in lst:
-                               lst.append(path)
-
-       for path in self.to_list(self.includes):
-               if not path in lst:
-                       if preproc.go_absolute or path[0] != '/': #os.path.isabs(path):
-                               lst.append(path)
-                       else:
-                               self.env.prepend_value('CPPPATH', path)
-
-       for path in lst:
-               node = None
-               if path[0] == '/': # os.path.isabs(path):
-                       if preproc.go_absolute:
-                               node = self.bld.root.find_dir(path)
-               elif path[0] == '#':
-                       node = self.bld.srcnode
-                       if len(path) > 1:
-                               try:
-                                       node = kak[path]
-                               except KeyError:
-                                       kak[path] = node = node.find_dir(path[1:])
-               else:
-                       try:
-                               node = kak[(self.path.id, path)]
-                       except KeyError:
-                               kak[(self.path.id, path)] = node = self.path.find_dir(path)
-
-               if node:
-                       self.env.append_value('INC_PATHS', node)
+    lst = []
+
+    try:
+        kak = self.bld.kak
+    except AttributeError:
+        kak = self.bld.kak = {}
+
+    # TODO move the uselib processing out of here
+    for lib in self.to_list(self.uselib):
+        for path in self.env['CPPPATH_' + lib]:
+            if not path in lst:
+                lst.append(path)
+    if preproc.go_absolute:
+        for path in preproc.standard_includes:
+            if not path in lst:
+                lst.append(path)
+
+    for path in self.to_list(self.includes):
+        if not path in lst:
+            if preproc.go_absolute or path[0] != '/':  # os.path.isabs(path):
+                lst.append(path)
+            else:
+                self.env.prepend_value('CPPPATH', path)
+
+    for path in lst:
+        node = None
+        if path[0] == '/': # os.path.isabs(path):
+            if preproc.go_absolute:
+                node = self.bld.root.find_dir(path)
+        elif path[0] == '#':
+            node = self.bld.srcnode
+            if len(path) > 1:
+                try:
+                    node = kak[path]
+                except KeyError:
+                    kak[path] = node = node.find_dir(path[1:])
+        else:
+            try:
+                node = kak[(self.path.id, path)]
+            except KeyError:
+                kak[(self.path.id, path)] = node = self.path.find_dir(path)
+
+        if node:
+            self.env.append_value('INC_PATHS', node)
 
 @feature('cc')
 @after('apply_incpaths')
@@ -91,13 +91,13 @@ def apply_obj_vars_cc(self):
 import Node, Environment
 
 def vari(self):
-       return "default"
+    return "default"
 Environment.Environment.variant = vari
 
 def variant(self, env):
-       if not env: return 0
-       elif self.id & 3 == Node.FILE: return 0
-       else: return "default"
+    if not env: return 0
+    elif self.id & 3 == Node.FILE: return 0
+    else: return "default"
 Node.Node.variant = variant
 
 
@@ -113,13 +113,13 @@ def create_task(self, name, src=None, tgt=None):
 TaskGen.task_gen.create_task = create_task
 
 def hash_constraints(self):
-       a = self.attr
-       sum = hash((str(a('before', '')),
+    a = self.attr
+    sum = hash((str(a('before', '')),
             str(a('after', '')),
             str(a('ext_in', '')),
             str(a('ext_out', '')),
             self.__class__.maxjobs))
-       return sum
+    return sum
 Task.TaskBase.hash_constraints = hash_constraints
 
 
@@ -129,37 +129,37 @@ Task.TaskBase.hash_constraints = hash_constraints
 
 # @extension(cc.EXT_CC)
 # def c_hook(self, node):
-#      task = self.create_task('cc', node, node.change_ext('.o'))
-#      try:
-#              self.compiled_tasks.append(task)
-#      except AttributeError:
-#              raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self))
+#     task = self.create_task('cc', node, node.change_ext('.o'))
+#     try:
+#         self.compiled_tasks.append(task)
+#     except AttributeError:
+#         raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self))
 
-#      bld = self.bld
-#      try:
-#              dc = bld.dc
-#      except AttributeError:
-#              dc = bld.dc = {}
+#     bld = self.bld
+#     try:
+#         dc = bld.dc
+#     except AttributeError:
+#         dc = bld.dc = {}
 
-#      if task.outputs[0].id in dc:
-#              raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator))
-#      else:
-#              dc[task.outputs[0].id] = task
+#     if task.outputs[0].id in dc:
+#         raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator))
+#     else:
+#         dc[task.outputs[0].id] = task
 
-#      return task
+#     return task
 
 
 def suncc_wrap(cls):
-       '''work around a problem with cc on solaris not handling module aliases
-       which have empty libs'''
-       if getattr(cls, 'solaris_wrap', False):
-               return
-       cls.solaris_wrap = True
-       oldrun = cls.run
-       def run(self):
-               if self.env.CC_NAME == "sun" and not self.inputs:
-                       self.env = self.env.copy()
-                       self.env.append_value('LINKFLAGS', '-')
-               return oldrun(self)
-       cls.run = run
+    '''work around a problem with cc on solaris not handling module aliases
+    which have empty libs'''
+    if getattr(cls, 'solaris_wrap', False):
+        return
+    cls.solaris_wrap = True
+    oldrun = cls.run
+    def run(self):
+        if self.env.CC_NAME == "sun" and not self.inputs:
+            self.env = self.env.copy()
+            self.env.append_value('LINKFLAGS', '-')
+        return oldrun(self)
+    cls.run = run
 suncc_wrap(Task.TaskBase.classes['cc_link'])
index dc988c597ed4ae21afc6079a9504f87e5e809584..615d918ba633c089efb5558e685a1ae2e2f1c838 100644 (file)
@@ -21,7 +21,7 @@ def write_version_header(task):
 
 def SAMBA_MKVERSION(bld, target):
     '''generate the version.h header for Samba'''
-    t = bld.SAMBA_GENERATOR('VERSION', 
+    t = bld.SAMBA_GENERATOR('VERSION',
                             rule=write_version_header,
                             source= 'VERSION',
                             target=target,
index f40066eb69318ebed6c5fba0324cc7cbd98d262a..ff13971d34da8629b9ae372f6ae1a9456272e986 100644 (file)
@@ -31,8 +31,8 @@ def SAMBA_PIDL(bld, pname, source,
                     '--client'            : 'ndr_%s_c.c ndr_%s_c.h',
                     '--python'            : 'py_%s.c',
                     '--tdr-parser'        : 'tdr_%s.c tdr_%s.h',
-                    '--dcom-proxy'       : '%s_p.c',
-                    '--com-header'       : 'com_%s.h'
+                    '--dcom-proxy'        : '%s_p.c',
+                    '--com-header'        : 'com_%s.h'
                     }
 
     table_header_idx = None
index 503fa75185a76b01da39d92cecea95297efb6638..6bc32f00b65a6e6443494cffcb232f8ea4fd6270 100644 (file)
@@ -21,7 +21,7 @@ def SAMBA_PYTHON(bld, name,
                  realname=None,
                  cflags='',
                  includes='',
-                 init_function_sentinal=None,
+                 init_function_sentinel=None,
                  local_include=True,
                  vars=None,
                  enabled=True):
@@ -29,8 +29,8 @@ def SAMBA_PYTHON(bld, name,
 
     # when we support static python modules we'll need to gather
     # the list from all the SAMBA_PYTHON() targets
-    if init_function_sentinal is not None:
-        cflags += '-DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinal
+    if init_function_sentinel is not None:
+        cflags += '-DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinel
 
     source = bld.EXPAND_VARIABLES(source, vars=vars)
 
index 71cfbc5b60aca825b9661a6cc4bec2085cba2000..c1869df1c26a6d7cb2c7cef5cced73b229632754 100644 (file)
@@ -3,7 +3,7 @@
 
 import Build, os, sys, Options, Utils, Task, re, fnmatch, Logs
 from TaskGen import feature, before
-from Configure import conf
+from Configure import conf, ConfigurationContext
 from Logs import debug
 import shlex
 
@@ -215,6 +215,8 @@ def TO_LIST(str, delimiter=None):
         return []
     if isinstance(str, list):
         return str
+    if len(str) == 0:
+        return []
     lst = str.split(delimiter)
     # the string may have had quotes in it, now we
     # check if we did have quotes, and use the slower shlex
@@ -233,8 +235,7 @@ def subst_vars_error(string, env):
         if re.match('\$\{\w+\}', v):
             vname = v[2:-1]
             if not vname in env:
-                Logs.error("Failed to find variable %s in %s" % (vname, string))
-                sys.exit(1)
+                raise KeyError("Failed to find variable %s in %s" % (vname, string))
             v = env[vname]
         out.append(v)
     return ''.join(out)
@@ -255,7 +256,7 @@ def ENFORCE_GROUP_ORDERING(bld):
         @feature('*')
         @before('exec_rule', 'apply_core', 'collect')
         def force_previous_groups(self):
-            if getattr(self.bld, 'enforced_group_ordering', False) == True:
+            if getattr(self.bld, 'enforced_group_ordering', False):
                 return
             self.bld.enforced_group_ordering = True
 
@@ -273,7 +274,7 @@ def ENFORCE_GROUP_ORDERING(bld):
                         debug('group: Forcing up to group %s for target %s',
                               group_name(g), self.name or self.target)
                         break
-                if stop != None:
+                if stop is not None:
                     break
             if stop is None:
                 return
@@ -501,15 +502,15 @@ def CHECK_MAKEFLAGS(bld):
                 if v == 'j':
                     jobs_set = True
                 elif v == 'k':
-                    Options.options.keep = True                
+                    Options.options.keep = True
         elif opt == '-j':
             jobs_set = True
         elif opt == '-k':
-            Options.options.keep = True                
+            Options.options.keep = True
     if not jobs_set:
         # default to one job
         Options.options.jobs = 1
-            
+
 Build.BuildContext.CHECK_MAKEFLAGS = CHECK_MAKEFLAGS
 
 option_groups = {}
@@ -625,3 +626,35 @@ def get_tgt_list(bld):
             sys.exit(1)
         tgt_list.append(t)
     return tgt_list
+
+from Constants import WSCRIPT_FILE
+def PROCESS_SEPARATE_RULE(self, rule):
+    ''' cause waf to process additional script based on `rule'.
+        You should have file named wscript_<stage>_rule in the current directory
+        where stage is either 'configure' or 'build'
+    '''
+    ctxclass = self.__class__.__name__
+    stage = ''
+    if ctxclass == 'ConfigurationContext':
+        stage = 'configure'
+    elif ctxclass == 'BuildContext':
+        stage = 'build'
+    file_path = os.path.join(self.curdir, WSCRIPT_FILE+'_'+stage+'_'+rule)
+    txt = load_file(file_path)
+    if txt:
+        dc = {'ctx': self}
+        if getattr(self.__class__, 'pre_recurse', None):
+            dc = self.pre_recurse(txt, file_path, self.curdir)
+        exec(compile(txt, file_path, 'exec'), dc)
+        if getattr(self.__class__, 'post_recurse', None):
+            dc = self.post_recurse(txt, file_path, self.curdir)
+
+Build.BuildContext.PROCESS_SEPARATE_RULE = PROCESS_SEPARATE_RULE
+ConfigurationContext.PROCESS_SEPARATE_RULE = PROCESS_SEPARATE_RULE
+
+def AD_DC_BUILD_IS_ENABLED(self):
+    if self.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
+        return True
+    return False
+
+Build.BuildContext.AD_DC_BUILD_IS_ENABLED = AD_DC_BUILD_IS_ENABLED
index 96d5d0d47d314e2b2b694471ed3754497e26198c..67ff23240488e9636e419782d22dffd945f9ab89 100644 (file)
@@ -92,12 +92,47 @@ def git_version_summary(path, env=None):
     return (ret, fields)
 
 
+def distversion_version_summary(path):
+    #get version from .distversion file
+    f = open(path + '/.distversion', 'r')
+    suffix = None
+    fields = {}
+
+    for line in f:
+        line = line.strip()
+        if line == '':
+            continue
+        if line.startswith("#"):
+            continue
+        try:
+            split_line = line.split("=")
+            if split_line[1] != "":
+                key = split_line[0]
+                value = split_line[1]
+                if key == "SUFFIX":
+                    suffix = value
+                    continue
+                fields[key] = value
+        except:
+            print("Failed to parse line %s from .distversion file." % (line))
+            raise
+    f.close()
+
+    if "COMMIT_TIME" in fields:
+        fields["COMMIT_TIME"] = int(fields["COMMIT_TIME"])
+
+    if suffix is None:
+        return ("UNKNOWN", fields)
+
+    return (suffix, fields)
+
+
 class SambaVersion(object):
 
     def __init__(self, version_dict, path, env=None, is_install=True):
         '''Determine the version number of samba
 
-See VERSION for the format.  Entries on that file are 
+See VERSION for the format.  Entries on that file are
 also accepted as dictionary entries here
         '''
 
@@ -107,6 +142,7 @@ also accepted as dictionary entries here
         self.REVISION=None
         self.TP_RELEASE=None
         self.ALPHA_RELEASE=None
+        self.BETA_RELEASE=None
         self.PRE_RELEASE=None
         self.RC_RELEASE=None
         self.IS_SNAPSHOT=True
@@ -137,7 +173,7 @@ also accepted as dictionary entries here
         SAMBA_VERSION_STRING = ("%u.%u.%u" % (self.MAJOR, self.MINOR, self.RELEASE))
 
 ##
-## maybe add "3.0.22a" or "4.0.0tp11" or "4.0.0alpha1" or "3.0.22pre1" or "3.0.22rc1"
+## maybe add "3.0.22a" or "4.0.0tp11" or "4.0.0alpha1" or "4.0.0beta1" or "3.0.22pre1" or "3.0.22rc1"
 ## We do not do pre or rc version on patch/letter releases
 ##
         if self.REVISION is not None:
@@ -148,6 +184,9 @@ also accepted as dictionary entries here
         if self.ALPHA_RELEASE is not None:
             self.ALPHA_RELEASE = int(self.ALPHA_RELEASE)
             SAMBA_VERSION_STRING += ("alpha%u" % self.ALPHA_RELEASE)
+        if self.BETA_RELEASE is not None:
+            self.BETA_RELEASE = int(self.BETA_RELEASE)
+            SAMBA_VERSION_STRING += ("beta%u" % self.BETA_RELEASE)
         if self.PRE_RELEASE is not None:
             self.PRE_RELEASE = int(self.PRE_RELEASE)
             SAMBA_VERSION_STRING += ("pre%u" % self.PRE_RELEASE)
@@ -163,9 +202,12 @@ also accepted as dictionary entries here
                 suffix, self.vcs_fields = git_version_summary(path, env=env)
             elif os.path.exists(os.path.join(path, ".bzr")):
                 suffix, self.vcs_fields = bzr_version_summary(path)
+            elif os.path.exists(os.path.join(path, ".distversion")):
+                suffix, self.vcs_fields = distversion_version_summary(path)
             else:
                 suffix = "UNKNOWN"
                 self.vcs_fields = {}
+            self.vcs_fields["SUFFIX"] = suffix
             SAMBA_VERSION_STRING += "-" + suffix
         else:
             self.vcs_fields = {}
@@ -201,6 +243,9 @@ also accepted as dictionary entries here
         if self.ALPHA_RELEASE is not None:
             string+="#define SAMBA_VERSION_ALPHA_RELEASE %u\n" % self.ALPHA_RELEASE
 
+        if self.BETA_RELEASE is not None:
+            string+="#define SAMBA_VERSION_BETA_RELEASE %u\n" % self.BETA_RELEASE
+
         if self.PRE_RELEASE is not None:
             string+="#define SAMBA_VERSION_PRE_RELEASE %u\n" % self.PRE_RELEASE
 
index 75ab5defcdca1caf26edce3b42cec4c6180680f6..84503b8f05786818c316cde4af7ccce458b92770 100644 (file)
@@ -1,5 +1,3 @@
-#! /usr/bin/env python
-
 # based on playground/evil in the waf svn tree
 
 import os, datetime
@@ -8,148 +6,148 @@ from Constants import *
 from samba_utils import *
 
 def run_task(t, k):
-       '''run a single build task'''
-       ret = t.run()
-       if ret:
-               raise Utils.WafError("Failed to build %s: %u" % (k, ret))
+    '''run a single build task'''
+    ret = t.run()
+    if ret:
+        raise Utils.WafError("Failed to build %s: %u" % (k, ret))
 
 
 def run_named_build_task(cmd):
-       '''run a named build task, matching the cmd name using fnmatch
-       wildcards against inputs and outputs of all build tasks'''
-       bld = fake_build_environment(info=False)
-       found = False
-       cwd_node = bld.root.find_dir(os.getcwd())
-       top_node = bld.root.find_dir(bld.srcnode.abspath())
+    '''run a named build task, matching the cmd name using fnmatch
+    wildcards against inputs and outputs of all build tasks'''
+    bld = fake_build_environment(info=False)
+    found = False
+    cwd_node = bld.root.find_dir(os.getcwd())
+    top_node = bld.root.find_dir(bld.srcnode.abspath())
 
-       cmd = os.path.normpath(cmd)
+    cmd = os.path.normpath(cmd)
 
-       # cope with builds of bin/*/*
-       if os.path.islink(cmd):
-               cmd = os_path_relpath(os.readlink(cmd), os.getcwd())
+    # cope with builds of bin/*/*
+    if os.path.islink(cmd):
+        cmd = os_path_relpath(os.readlink(cmd), os.getcwd())
 
-       if cmd[0:12] == "bin/default/":
-               cmd = cmd[12:]
+    if cmd[0:12] == "bin/default/":
+        cmd = cmd[12:]
 
-       for g in bld.task_manager.groups:
-               for attr in ['outputs', 'inputs']:
-                       for t in g.tasks:
-                               s = getattr(t, attr, [])
-                               for k in s:
-                                       relpath1 = k.relpath_gen(cwd_node)
-                                       relpath2 = k.relpath_gen(top_node)
-                                       if (fnmatch.fnmatch(relpath1, cmd) or
-                                           fnmatch.fnmatch(relpath2, cmd)):
-                                               t.position = [0,0]
-                                               print(t.display())
-                                               run_task(t, k)
-                                               found = True
+    for g in bld.task_manager.groups:
+        for attr in ['outputs', 'inputs']:
+            for t in g.tasks:
+                s = getattr(t, attr, [])
+                for k in s:
+                    relpath1 = k.relpath_gen(cwd_node)
+                    relpath2 = k.relpath_gen(top_node)
+                    if (fnmatch.fnmatch(relpath1, cmd) or
+                        fnmatch.fnmatch(relpath2, cmd)):
+                        t.position = [0,0]
+                        print(t.display())
+                        run_task(t, k)
+                        found = True
 
 
-       if not found:
-               raise Utils.WafError("Unable to find build target matching %s" % cmd)
+    if not found:
+        raise Utils.WafError("Unable to find build target matching %s" % cmd)
 
 
 def rewrite_compile_targets():
-       '''cope with the bin/ form of compile target'''
-       if not Options.options.compile_targets:
-               return
+    '''cope with the bin/ form of compile target'''
+    if not Options.options.compile_targets:
+        return
 
-       bld = fake_build_environment(info=False)
-       targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
-       tlist = []
+    bld = fake_build_environment(info=False)
+    targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
+    tlist = []
 
-       for t in Options.options.compile_targets.split(','):
-               if not os.path.islink(t):
-                       tlist.append(t)
-                       continue
-               link = os.readlink(t)
-               list = link.split('/')
-               for name in [list[-1], '/'.join(list[-2:])]:
-                       if name in targets:
-                               tlist.append(name)
-                               continue
-       Options.options.compile_targets = ",".join(tlist)
+    for t in Options.options.compile_targets.split(','):
+        if not os.path.islink(t):
+            tlist.append(t)
+            continue
+        link = os.readlink(t)
+        list = link.split('/')
+        for name in [list[-1], '/'.join(list[-2:])]:
+            if name in targets:
+                tlist.append(name)
+                continue
+    Options.options.compile_targets = ",".join(tlist)
 
 
 
 def wildcard_main(missing_cmd_fn):
-       '''this replaces main from Scripting, allowing us to override the
-          behaviour for unknown commands
+    '''this replaces main from Scripting, allowing us to override the
+       behaviour for unknown commands
 
-          If a unknown command is found, then missing_cmd_fn() is called with
-          the name of the requested command
-          '''
-       Scripting.commands = Options.arg_line[:]
+       If a unknown command is found, then missing_cmd_fn() is called with
+       the name of the requested command
+       '''
+    Scripting.commands = Options.arg_line[:]
 
-       # rewrite the compile targets to cope with the bin/xx form
-       rewrite_compile_targets()
+    # rewrite the compile targets to cope with the bin/xx form
+    rewrite_compile_targets()
 
-       while Scripting.commands:
-               x = Scripting.commands.pop(0)
+    while Scripting.commands:
+        x = Scripting.commands.pop(0)
 
-               ini = datetime.datetime.now()
-               if x == 'configure':
-                       fun = Scripting.configure
-               elif x == 'build':
-                       fun = Scripting.build
-               else:
-                       fun = getattr(Utils.g_module, x, None)
+        ini = datetime.datetime.now()
+        if x == 'configure':
+            fun = Scripting.configure
+        elif x == 'build':
+            fun = Scripting.build
+        else:
+            fun = getattr(Utils.g_module, x, None)
 
-               # this is the new addition on top of main from Scripting.py
-               if not fun:
-                       missing_cmd_fn(x)
-                       break
+        # this is the new addition on top of main from Scripting.py
+        if not fun:
+            missing_cmd_fn(x)
+            break
 
-               ctx = getattr(Utils.g_module, x + '_context', Utils.Context)()
+        ctx = getattr(Utils.g_module, x + '_context', Utils.Context)()
 
-               if x in ['init', 'shutdown', 'dist', 'distclean', 'distcheck']:
-                       try:
-                               fun(ctx)
-                       except TypeError:
-                               fun()
-               else:
-                       fun(ctx)
+        if x in ['init', 'shutdown', 'dist', 'distclean', 'distcheck']:
+            try:
+                fun(ctx)
+            except TypeError:
+                fun()
+        else:
+            fun(ctx)
 
-               ela = ''
-               if not Options.options.progress_bar:
-                       ela = ' (%s)' % Utils.get_elapsed_time(ini)
+        ela = ''
+        if not Options.options.progress_bar:
+            ela = ' (%s)' % Utils.get_elapsed_time(ini)
 
-               if x != 'init' and x != 'shutdown':
-                       Logs.info('%r finished successfully%s' % (x, ela))
+        if x != 'init' and x != 'shutdown':
+            Logs.info('%r finished successfully%s' % (x, ela))
 
-               if not Scripting.commands and x != 'shutdown':
-                       Scripting.commands.append('shutdown')
+        if not Scripting.commands and x != 'shutdown':
+            Scripting.commands.append('shutdown')
 
 
 
 
 def fake_build_environment(info=True, flush=False):
-       """create all the tasks for the project, but do not run the build
-       return the build context in use"""
-       bld = getattr(Utils.g_module, 'build_context', Utils.Context)()
-       bld = Scripting.check_configured(bld)
+    """create all the tasks for the project, but do not run the build
+    return the build context in use"""
+    bld = getattr(Utils.g_module, 'build_context', Utils.Context)()
+    bld = Scripting.check_configured(bld)
 
-       Options.commands['install'] = False
-       Options.commands['uninstall'] = False
-       Options.is_install = False
+    Options.commands['install'] = False
+    Options.commands['uninstall'] = False
+    Options.is_install = False
 
-       bld.is_install = 0 # False
+    bld.is_install = 0 # False
 
-       try:
-               proj = Environment.Environment(Options.lockfile)
-       except IOError:
-               raise Utils.WafError("Project not configured (run 'waf configure' first)")
+    try:
+        proj = Environment.Environment(Options.lockfile)
+    except IOError:
+        raise Utils.WafError("Project not configured (run 'waf configure' first)")
 
-       bld.load_dirs(proj[SRCDIR], proj[BLDDIR])
-       bld.load_envs()
+    bld.load_dirs(proj[SRCDIR], proj[BLDDIR])
+    bld.load_envs()
 
-       if info:
-               Logs.info("Waf: Entering directory `%s'" % bld.bldnode.abspath())
-       bld.add_subdirs([os.path.split(Utils.g_module.root_path)[0]])
+    if info:
+        Logs.info("Waf: Entering directory `%s'" % bld.bldnode.abspath())
+    bld.add_subdirs([os.path.split(Utils.g_module.root_path)[0]])
 
-       bld.pre_build()
-       if flush:
-               bld.flush()
-       return bld
+    bld.pre_build()
+    if flush:
+        bld.flush()
+    return bld
 
index 1ee1ff9d4471197234d7950207b56fbd8dd3c517..2dd08e14974e6cfe7cb24df7894cec04694a537c 100644 (file)
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 # encoding: utf-8
 # Thomas Nagy, 2006-2010 (ita)
 
@@ -48,7 +47,7 @@ def replace_refill_task_list(self):
     # paranoia
     if bin_base[-4:] != '/bin':
         raise Utils.WafError("Invalid bin base: %s" % bin_base)
-    
+
     # obtain the expected list of files
     expected = []
     for i in range(len(bld.task_manager.groups)):
index 87757357afce6811cd358e0005c5e5fc34f5afbd..13d84b9a41201d438647925c32031064b00c6c01 100644 (file)
@@ -592,6 +592,8 @@ def symbols_dupcheck_binary(bld, binname, fail_on_error):
     symmap = {}
     for libpath in symlist:
         for sym in symlist[libpath]['PUBLIC']:
+            if sym == '_GLOBAL_OFFSET_TABLE_':
+                continue
             if not sym in symmap:
                 symmap[sym] = set()
             symmap[sym].add(libpath)
@@ -645,7 +647,7 @@ def SYMBOL_CHECK(bld):
 Build.BuildContext.SYMBOL_CHECK = SYMBOL_CHECK
 
 def DUP_SYMBOL_CHECK(bld):
-    if Options.options.DUP_SYMBOLCHECK and bld.env.DEVELOPER and not bld.env.BUILD_FARM:
+    if Options.options.DUP_SYMBOLCHECK and bld.env.DEVELOPER:
         '''check for duplicate symbols'''
         bld.SET_BUILD_GROUP('syslibcheck')
         task = bld(rule=symbols_dupcheck_fatal, always=True, name='symbol duplicate checking')
diff --git a/buildtools/wafsamba/tests/__init__.py b/buildtools/wafsamba/tests/__init__.py
new file mode 100644 (file)
index 0000000..ae27418
--- /dev/null
@@ -0,0 +1,35 @@
+# Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for wafsamba."""
+
+from unittest import (
+    TestCase,
+    TestLoader,
+    )
+
+def test_suite():
+    names = [
+        'abi',
+        'bundled',
+        'utils',
+        ]
+    module_names = ['wafsamba.tests.test_' + name for name in names]
+    loader = TestLoader()
+    result = loader.suiteClass()
+    suite = loader.loadTestsFromNames(module_names)
+    result.addTests(suite)
+    return result
diff --git a/buildtools/wafsamba/tests/test_abi.py b/buildtools/wafsamba/tests/test_abi.py
new file mode 100644 (file)
index 0000000..0aa0d56
--- /dev/null
@@ -0,0 +1,53 @@
+# Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+from wafsamba.tests import TestCase
+
+from wafsamba.samba_abi import (
+    normalise_signature,
+    )
+
+
+class NormaliseSignatureTests(TestCase):
+
+    def test_function_simple(self):
+        self.assertEquals("int (const struct GUID *, const struct GUID *)",
+            normalise_signature("$2 = {int (const struct GUID *, const struct GUID *)} 0xe871 <GUID_compare>"))
+
+    def test_maps_Bool(self):
+        # Some types have different internal names
+        self.assertEquals("bool (const struct GUID *)",
+            normalise_signature("$1 = {_Bool (const struct GUID *)} 0xe75b <GUID_all_zero>"))
+
+    def test_function_keep(self):
+        self.assertEquals(
+            "enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *)",
+            normalise_signature("enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *)"))
+
+    def test_struct_constant(self):
+        self.assertEquals(
+            'uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\\000", node = "\\000\\000\\000\\000\\000"}, if_version = 0',
+            normalise_signature('$239 = {uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\\000", node = "\\000\\000\\000\\000\\000"}, if_version = 0}'))
+
+    def test_incomplete_sequence(self):
+        # Newer versions of gdb insert these incomplete sequence elements
+        self.assertEquals(
+            'uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237\\350", node = "\\b\\000+\\020H`"}, if_version = 2',
+            normalise_signature('$244 = {uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237", <incomplete sequence \\350>, node = "\\b\\000+\\020H`"}, if_version = 2}'))
+        self.assertEquals(
+            'uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237\\350", node = "\\b\\000+\\020H`"}, if_version = 2',
+            normalise_signature('$244 = {uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237\\350", node = "\\b\\000+\\020H`"}, if_version = 2}'))
+
diff --git a/buildtools/wafsamba/tests/test_bundled.py b/buildtools/wafsamba/tests/test_bundled.py
new file mode 100644 (file)
index 0000000..c5f0db6
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+from wafsamba.tests import TestCase
+
+from wafsamba.samba_bundled import (
+    tuplize_version,
+    )
+
+
+class TuplizeVersionTests(TestCase):
+
+    def test_simple(self):
+        self.assertEquals((1, 2, 10), tuplize_version("1.2.10"))
diff --git a/buildtools/wafsamba/tests/test_utils.py b/buildtools/wafsamba/tests/test_utils.py
new file mode 100644 (file)
index 0000000..a9578e2
--- /dev/null
@@ -0,0 +1,76 @@
+# Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+from wafsamba.tests import TestCase
+
+from wafsamba.samba_utils import (
+    TO_LIST,
+    dict_concat,
+    subst_vars_error,
+    unique_list,
+    )
+
+class ToListTests(TestCase):
+
+    def test_none(self):
+        self.assertEquals([], TO_LIST(None))
+
+    def test_already_list(self):
+        self.assertEquals(["foo", "bar", 1], TO_LIST(["foo", "bar", 1]))
+
+    def test_default_delimiter(self):
+        self.assertEquals(["foo", "bar"], TO_LIST("foo bar"))
+        self.assertEquals(["foo", "bar"], TO_LIST("  foo bar  "))
+        self.assertEquals(["foo ", "bar"], TO_LIST("  \"foo \" bar  "))
+
+    def test_delimiter(self):
+        self.assertEquals(["foo", "bar"], TO_LIST("foo,bar", ","))
+        self.assertEquals(["  foo", "bar  "], TO_LIST("  foo,bar  ", ","))
+        self.assertEquals(["  \" foo\"", " bar  "], TO_LIST("  \" foo\", bar  ", ","))
+
+
+class UniqueListTests(TestCase):
+
+    def test_unique_list(self):
+        self.assertEquals(["foo", "bar"], unique_list(["foo", "bar", "foo"]))
+
+
+class SubstVarsErrorTests(TestCase):
+
+    def test_valid(self):
+        self.assertEquals("", subst_vars_error("", {}))
+        self.assertEquals("FOO bar", subst_vars_error("${F} bar", {"F": "FOO"}))
+
+    def test_invalid(self):
+        self.assertRaises(KeyError, subst_vars_error, "${F}", {})
+
+
+class DictConcatTests(TestCase):
+
+    def test_empty(self):
+        ret = {}
+        dict_concat(ret, {})
+        self.assertEquals({}, ret)
+
+    def test_same(self):
+        ret = {"foo": "bar"}
+        dict_concat(ret, {"foo": "bla"})
+        self.assertEquals({"foo": "bar"}, ret)
+
+    def test_simple(self):
+        ret = {"foo": "bar"}
+        dict_concat(ret, {"blie": "bla"})
+        self.assertEquals({"foo": "bar", "blie": "bla"}, ret)
index 7e85701536b04e519b7c08479fcd6ddabb7b73c2..e1bbb1d885894ef0dc9e7ceaad3a8ee9f96de4cb 100644 (file)
@@ -13,57 +13,57 @@ c_compiler['osf1V'] = ['gcc', 'tru64cc']
 
 @conftest
 def find_tru64cc(conf):
-       v = conf.env
-       cc = None
-       if v['CC']: cc = v['CC']
-       elif 'CC' in conf.environ: cc = conf.environ['CC']
-       if not cc: cc = conf.find_program('cc', var='CC')
-       if not cc: conf.fatal('tru64cc was not found')
-       cc = conf.cmd_to_list(cc)
-
-       try:
-               if not Utils.cmd_output(cc + ['-V']):
-                       conf.fatal('tru64cc %r was not found' % cc)
-       except ValueError:
-               conf.fatal('tru64cc -V could not be executed')
-
-       v['CC']  = cc
-       v['CC_NAME'] = 'tru64'
+    v = conf.env
+    cc = None
+    if v['CC']: cc = v['CC']
+    elif 'CC' in conf.environ: cc = conf.environ['CC']
+    if not cc: cc = conf.find_program('cc', var='CC')
+    if not cc: conf.fatal('tru64cc was not found')
+    cc = conf.cmd_to_list(cc)
+
+    try:
+        if not Utils.cmd_output(cc + ['-V']):
+            conf.fatal('tru64cc %r was not found' % cc)
+    except ValueError:
+        conf.fatal('tru64cc -V could not be executed')
+
+    v['CC']  = cc
+    v['CC_NAME'] = 'tru64'
 
 @conftest
 def tru64cc_common_flags(conf):
-       v = conf.env
-
-       v['CC_SRC_F']            = ''
-       v['CC_TGT_F']            = ['-c', '-o', '']
-       v['CPPPATH_ST']          = '-I%s' # template for adding include paths
-
-       # linker
-       if not v['LINK_CC']: v['LINK_CC'] = v['CC']
-       v['CCLNK_SRC_F']         = ''
-       v['CCLNK_TGT_F']         = ['-o', '']
-
-       v['LIB_ST']              = '-l%s' # template for adding libs
-       v['LIBPATH_ST']          = '-L%s' # template for adding libpaths
-       v['STATICLIB_ST']        = '-l%s'
-       v['STATICLIBPATH_ST']    = '-L%s'
-       v['CCDEFINES_ST']        = '-D%s'
-
-#      v['SONAME_ST']           = '-Wl,-h -Wl,%s'
-#      v['SHLIB_MARKER']        = '-Bdynamic'
-#      v['STATICLIB_MARKER']    = '-Bstatic'
-
-       # program
-       v['program_PATTERN']     = '%s'
-
-       # shared library
-#      v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
-       v['shlib_LINKFLAGS']     = ['-shared']
-       v['shlib_PATTERN']       = 'lib%s.so'
-
-       # static lib
-#      v['staticlib_LINKFLAGS'] = ['-Bstatic']
-#      v['staticlib_PATTERN']   = 'lib%s.a'
+    v = conf.env
+
+    v['CC_SRC_F']            = ''
+    v['CC_TGT_F']            = ['-c', '-o', '']
+    v['CPPPATH_ST']          = '-I%s' # template for adding include paths
+
+    # linker
+    if not v['LINK_CC']: v['LINK_CC'] = v['CC']
+    v['CCLNK_SRC_F']         = ''
+    v['CCLNK_TGT_F']         = ['-o', '']
+
+    v['LIB_ST']              = '-l%s' # template for adding libs
+    v['LIBPATH_ST']          = '-L%s' # template for adding libpaths
+    v['STATICLIB_ST']        = '-l%s'
+    v['STATICLIBPATH_ST']    = '-L%s'
+    v['CCDEFINES_ST']        = '-D%s'
+
+#    v['SONAME_ST']           = '-Wl,-h -Wl,%s'
+#    v['SHLIB_MARKER']        = '-Bdynamic'
+#    v['STATICLIB_MARKER']    = '-Bstatic'
+
+    # program
+    v['program_PATTERN']     = '%s'
+
+    # shared library
+#    v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
+    v['shlib_LINKFLAGS']     = ['-shared']
+    v['shlib_PATTERN']       = 'lib%s.so'
+
+    # static lib
+#    v['staticlib_LINKFLAGS'] = ['-Bstatic']
+#    v['staticlib_PATTERN']   = 'lib%s.a'
 
 detect = '''
 find_tru64cc
index fd72cf322907f4e1c8be9df8116ba0aae2a14b7c..59d3a2c02f939a61545116ca6174a9965880d666 100644 (file)
@@ -31,6 +31,7 @@ import samba_wildcard
 import stale_files
 import symbols
 import pkgconfig
+import configure_file
 
 # some systems have broken threading in python
 if os.environ.get('WAF_NOTHREADS') == '1':
@@ -132,6 +133,9 @@ def SAMBA_LIBRARY(bld, libname, source,
                   enabled=True):
     '''define a Samba library'''
 
+    if LIB_MUST_BE_PRIVATE(bld, libname):
+        private_library=True
+
     if not enabled:
         SET_TARGET_TYPE(bld, libname, 'DISABLED')
         return
@@ -281,7 +285,7 @@ def SAMBA_LIBRARY(bld, libname, source,
     if pc_files is not None and not private_library:
         bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
 
-    if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and 
+    if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
         bld.env['XSLTPROC_MANPAGES']):
         bld.MANPAGES(manpages)
 
@@ -401,6 +405,7 @@ def SAMBA_MODULE(bld, modname, source,
                  subdir=None,
                  enabled=True,
                  pyembed=False,
+                 manpages=None,
                  allow_undefined_symbols=False
                  ):
     '''define a Samba module.'''
@@ -410,6 +415,9 @@ def SAMBA_MODULE(bld, modname, source,
         source = bld.SUBDIR(subdir, source)
 
     if internal_module or BUILTIN_LIBRARY(bld, modname):
+        # Do not create modules for disabled subsystems
+        if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
+            return
         bld.SAMBA_SUBSYSTEM(modname, source,
                     deps=deps,
                     includes=includes,
@@ -427,6 +435,10 @@ def SAMBA_MODULE(bld, modname, source,
         SET_TARGET_TYPE(bld, modname, 'DISABLED')
         return
 
+    # Do not create modules for disabled subsystems
+    if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
+        return
+
     obj_target = modname + '.objlist'
 
     realname = modname
@@ -459,6 +471,7 @@ def SAMBA_MODULE(bld, modname, source,
                       link_name=build_link_name,
                       install_path="${MODULESDIR}/%s" % subsystem,
                       pyembed=pyembed,
+                      manpages=manpages,
                       allow_undefined_symbols=allow_undefined_symbols
                       )
 
@@ -477,7 +490,7 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
                     cflags='',
                     cflags_end=None,
                     group='main',
-                    init_function_sentinal=None,
+                    init_function_sentinel=None,
                     autoproto=None,
                     autoproto_extra_source='',
                     depends_on='',
@@ -567,6 +580,12 @@ def SAMBA_GENERATOR(bld, name, rule, source='', target='',
     if not enabled:
         return
 
+    dep_vars = []
+    if isinstance(vars, dict):
+        dep_vars = vars.keys()
+    elif isinstance(vars, list):
+        dep_vars = vars
+
     bld.SET_BUILD_GROUP(group)
     t = bld(
         rule=rule,
@@ -577,7 +596,7 @@ def SAMBA_GENERATOR(bld, name, rule, source='', target='',
         before='cc',
         ext_out='.c',
         samba_type='GENERATOR',
-        dep_vars = [rule] + (vars or []),
+        dep_vars = [rule] + dep_vars,
         name=name)
 
     if always:
@@ -651,7 +670,7 @@ def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
     bld.SET_BUILD_GROUP('build_source')
     for s in TO_LIST(source):
         iname = s
-        if installname != None:
+        if installname is not None:
             iname = installname
         target = os.path.join(installdir, iname)
         tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
@@ -761,11 +780,28 @@ def MANPAGES(bld, manpages):
                             source=source,
                             target=m,
                             group='final',
-                            rule='${XSLTPROC} -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
+                            rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
                             )
         bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
 Build.BuildContext.MANPAGES = MANPAGES
 
+def SAMBAMANPAGES(bld, manpages):
+    '''build and install manual pages'''
+    bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
+    bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
+    bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file://' + bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
+    for m in manpages.split():
+        source = m + '.xml'
+        bld.SAMBA_GENERATOR(m,
+                            source=source,
+                            target=m,
+                            group='final',
+                            rule='''export XML_CATALOG_FILES="${SAMBA_CATALOGS}"
+                                    ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC}
+                                    ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
+                            )
+        bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
+Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
 
 #############################################################
 # give a nicer display when building different types of files
index 5c5e249758c36a64083499b9050c0c4e77c87b6d..5e1898c435d77de51076b4566627ff50f3777323 100755 (executable)
@@ -27,6 +27,10 @@ def set_options(opt):
                    help=("comma separated list of bundled libraries. May include !LIBNAME to disable bundling a library. Can be 'NONE' or 'ALL' [auto]"),
                    action="store", dest='BUNDLED_LIBS', default='')
 
+    gr.add_option('--private-libraries',
+                   help=("comma separated list of normally public libraries to build instead as private libraries. May include !LIBNAME to disable making a library private. Can be 'NONE' or 'ALL' [auto]"),
+                   action="store", dest='PRIVATE_LIBS', default='')
+
     extension_default = Options.options['PRIVATE_EXTENSION_DEFAULT']
     gr.add_option('--private-library-extension',
                    help=("name extension for private libraries [%s]" % extension_default),
@@ -73,6 +77,15 @@ def set_options(opt):
                    help=("private library directory [PREFIX/lib/%s]" % Utils.g_module.APPNAME),
                    action="store", dest='PRIVATELIBDIR', default=None)
 
+    opt.add_option('--with-libiconv',
+                   help='additional directory to search for libiconv',
+                   action='store', dest='iconv_open', default='/usr/local',
+                   match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h'])
+    opt.add_option('--with-gettext',
+                   help='additional directory to search for gettext',
+                   action='store', dest='gettext_location', default='/usr/local',
+                   match = ['Checking for library intl', 'Checking for header libintl.h'])
+
     gr = opt.option_group('developer options')
 
     gr.add_option('-C',
@@ -81,6 +94,9 @@ def set_options(opt):
     gr.add_option('--enable-auto-reconfigure',
                    help='enable automatic reconfigure on build',
                    action='store_true', dest='enable_auto_reconfigure')
+    gr.add_option('--enable-debug',
+                   help=("Turn on debugging symbols"),
+                   action="store_true", dest='debug', default=False)
     gr.add_option('--enable-developer',
                    help=("Turn on developer warnings and debugging"),
                    action="store_true", dest='developer', default=False)
@@ -156,6 +172,9 @@ def set_options(opt):
     opt.add_option('--host',
                   help=SUPPRESS_HELP,
                   action='store', dest='AUTOCONF_HOST', default='')
+    opt.add_option('--target',
+                  help=SUPPRESS_HELP,
+                  action='store', dest='AUTOCONF_TARGET', default='')
     opt.add_option('--program-prefix',
                   help=SUPPRESS_HELP,
                   action='store', dest='AUTOCONF_PROGRAM_PREFIX', default='')
@@ -227,6 +246,7 @@ def configure(conf):
     conf.env.MODULESDIR = Options.options.MODULESDIR
     conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR
     conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
+    conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',')
     conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
     conf.env.DISABLE_SHARED = Options.options.disable_shared
     conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',')
@@ -350,11 +370,17 @@ def configure(conf):
     conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
                        add_headers=True)
     conf.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers=True)
-    conf.CHECK_HEADERS('ctype.h standards.h stdbool.h stdint.h stdarg.h vararg.h', add_headers=True)
+    conf.CHECK_HEADERS('ctype.h', add_headers=True)
+
+    if sys.platform != 'darwin':
+        conf.CHECK_HEADERS('standards.h', add_headers=True)
+
+    conf.CHECK_HEADERS('stdbool.h stdint.h stdarg.h vararg.h', add_headers=True)
     conf.CHECK_HEADERS('limits.h assert.h')
 
     # see if we need special largefile flags
-    conf.CHECK_LARGEFILE()
+    if not conf.CHECK_LARGEFILE():
+        raise Utils.WafError('Samba requires large file support support, but not available on this platform: sizeof(off_t) < 8')
 
     if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
         conf.DEFINE('STDC_HEADERS', 1)
diff --git a/doc/context.png b/doc/context.png
new file mode 100644 (file)
index 0000000..48a6ca0
Binary files /dev/null and b/doc/context.png differ
diff --git a/doc/context_tree.png b/doc/context_tree.png
new file mode 100644 (file)
index 0000000..9723459
Binary files /dev/null and b/doc/context_tree.png differ
index 3204e8a5c2622f58f512dd5baf070dbe6a1dece1..3b56898a08759adddbf194d40145eb43064129cb 100644 (file)
  * <a href="http://samba.org/ftp/talloc" target="_blank">talloc directory</a>
  * on the samba public source archive.
  *
+ * @section main-tutorial Tutorial
+ *
+ * You should start by reading @subpage libtalloc_tutorial, then reading the documentation of
+ * the interesting functions as you go.
+
  * @section talloc_bugs Discussion and bug reports
  *
  * talloc does not currently have its own mailing list or bug tracking system.
diff --git a/doc/stealing.png b/doc/stealing.png
new file mode 100644 (file)
index 0000000..8833e06
Binary files /dev/null and b/doc/stealing.png differ
diff --git a/doc/tutorial_bestpractices.dox b/doc/tutorial_bestpractices.dox
new file mode 100644 (file)
index 0000000..3634446
--- /dev/null
@@ -0,0 +1,192 @@
+/**
+@page libtalloc_bestpractices Chapter 7: Best practises
+
+The following sections contain several best practices and good manners that were
+found by the <a href="http://www.samba.org">Samba</a> and
+<a href="https://fedorahosted.org/sssd">SSSD</a> developers over the years.
+These will help you to write code which is better, easier to debug and with as
+few (hopefully none) memory leaks as possible.
+
+@section bp-hierarchy Keep the context hierarchy steady
+
+The talloc is a hierarchy memory allocator. The hierarchy nature is what makes
+the programming more error proof. It makes the memory easier to manage and to
+free.  Therefore, the first thing we should have on our mind is: always project
+your data structures into the talloc context hierarchy.
+
+That means if we have a structure, we should always use it as a parent context
+for its elements. This way we will not encounter any troubles when freeing the
+structure or when changing its parent. The same rule applies for arrays.
+
+For example, the structure <code>user</code> from section @ref context-hierarchy
+should be created with the context hierarchy illustrated on the next image.
+
+@image html context_tree.png
+
+@section bp-tmpctx Every function should use its own context
+
+It is a good practice to create a temporary talloc context at the function
+beginning and free the context just before the return statement. All the data
+must be allocated on this context or on its children. This ensures that no
+memory leaks are created as long as we do not forget to free the temporary
+context.
+
+This pattern applies to both situations - when a function does not return any
+dynamically allocated value and when it does. However, it needs a little
+extension for the latter case.
+
+@subsection bp-tmpctx-1 Functions that do not return any dynamically allocated
+value
+
+If the function does not return any value created on the heap, we will just obey
+the aforementioned pattern.
+
+@code
+int bar()
+{
+  int ret;
+  TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+  if (tmp_ctx == NULL) {
+    ret = ENOMEM;
+    goto done;
+  }
+  /* allocate data on tmp_ctx or on its descendants */
+  ret = EOK;
+done:
+  talloc_free(tmp_ctx);
+  return ret;
+}
+@endcode
+
+@subsection bp-tmpctx-2 Functions returning dynamically allocated values
+
+If our function returns any dynamically allocated data, its first parameter
+should always be the destination talloc context. This context serves as a parent
+for the output values. But again, we will create the output values as the
+descendants of the temporary context. If everything goes well, we will change
+the parent of the output values from the temporary to the destination talloc
+context.
+
+This pattern ensures that if an error occurs (e.g. I/O error or insufficient
+amount of the memory), all allocated data is freed and no garbage appears on
+the destination context.
+
+@code
+int struct_foo_init(TALLOC_CTX *mem_ctx, struct foo **_foo)
+{
+  int ret;
+  struct foo *foo = NULL;
+  TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+  if (tmp_ctx == NULL) {
+    ret = ENOMEM;
+    goto done;
+  }
+  foo = talloc_zero(tmp_ctx, struct foo);
+  /* ... */
+  *_foo = talloc_steal(mem_ctx, foo);
+  ret = EOK;
+done:
+  talloc_free(tmp_ctx);
+  return ret;
+}
+@endcode
+
+@section bp-null Allocate temporary contexts on NULL
+
+As it can be seen on the previous listing, instead of allocating the temporary
+context directly on <code>mem_ctx</code>, we created a new top level context
+using <code>NULL</code> as the parameter for <code>talloc_new()</code> function.
+Take a look at the following example:
+
+@code
+char *create_user_filter(TALLOC_CTX *mem_ctx,
+                         uid_t uid, const char *username)
+{
+  char *filter = NULL;
+  char *sanitized_username = NULL;
+  /* tmp_ctx is a child of mem_ctx */
+  TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+  if (tmp_ctx == NULL) {
+    return NULL;
+  }
+
+  sanitized_username = sanitize_string(tmp_ctx, username);
+  if (sanitized_username == NULL) {
+    talloc_free(tmp_ctx);
+    return NULL;
+  }
+
+  filter = talloc_aprintf(tmp_ctx,"(|(uid=%llu)(uname=%s))",
+                          uid, sanitized_username);
+  if (filter == NULL) {
+    return NULL; /* tmp_ctx is not freed */ (*@\label{lst:tmp-ctx-3:leak}@*)
+  }
+
+  /* filter becomes a child of mem_ctx */
+  filter = talloc_steal(mem_ctx, filter);
+  talloc_free(tmp_ctx);
+  return filter;
+}
+@endcode
+
+We forgot to free <code>tmp_ctx</code> before the <code>return</code> statement
+in the <code>filter == NULL</code> condition. However, it is created as a child
+of <code>mem_ctx</code> context and as such it will be freed as soon as the
+<code>mem_ctx</code> is freed. Therefore, no detectable memory leak is created.
+
+On the other hand, we do not have any way to access the allocated data
+and for all we know <code>mem_ctx</code> may exist for the lifetime of our
+application. For these reasons this should be considered as a memory leak. How
+can we detect if it is unreferenced but still attached to its parent context?
+The only way is to notice the mistake in the source code.
+
+But if we create the temporary context as a top level context, it will not be
+freed and memory diagnostic tools
+(e.g. <a href="http://valgrind.org">valgrind</a>) are able to do their job.
+
+@section bp-pool Temporary contexts and the talloc pool
+
+If we want to take the advantage of the talloc pool but also keep to the
+pattern introduced in the previous section, we are unable to do it directly. The
+best thing to do is to create a conditional build where we can decide how do we
+want to create the temporary context. For example, we can create the following
+macros:
+
+@code
+#ifdef USE_POOL_CONTEXT
+  #define CREATE_POOL_CTX(ctx, size) talloc_pool(ctx, size)
+  #define CREATE_TMP_CTX(ctx)        talloc_new(ctx)
+#else
+  #define CREATE_POOL_CTX(ctx, size) talloc_new(ctx)
+  #define CREATE_TMP_CTX(ctx)        talloc_new(NULL)
+#endif
+@endcode
+
+Now if our application is under development, we will build it with macro
+<code>USE_POOL_CONTEXT</code> undefined. This way, we  can use memory diagnostic
+utilities to detect memory leaks.
+
+The release version will be compiled with the macro defined. This will  enable
+pool contexts and therefore reduce the <code>malloc()</code> calls, which will
+end up in a little bit faster processing.
+
+@code
+int struct_foo_init(TALLOC_CTX *mem_ctx, struct foo **_foo)
+{
+  int ret;
+  struct foo *foo = NULL;
+  TALLOC_CTX *tmp_ctx = CREATE_TMP_CTX(mem_ctx);
+  /* ... */
+}
+
+errno_t handle_request(TALLOC_CTX mem_ctx)
+{
+  int ret;
+  struct foo *foo = NULL;
+  TALLOC_CTX *pool_ctx = CREATE_POOL_CTX(NULL, 1024);
+  ret = struct_foo_init(mem_ctx, &foo);
+  /* ... */
+}
+@endcode
+
+*/
diff --git a/doc/tutorial_context.dox b/doc/tutorial_context.dox
new file mode 100644 (file)
index 0000000..b8bfe26
--- /dev/null
@@ -0,0 +1,198 @@
+/**
+@page libtalloc_context Chapter 1: Talloc context
+@section context Talloc context
+
+The talloc context is the most important part of this library and is
+responsible for every single feature of this memory allocator. It is a logical
+unit which represents a memory space managed by talloc.
+
+From the programmer's point of view, the talloc context is completely
+equivalent to a pointer that would be returned by the memory routines from the
+C standard library. This means that every context that is returned from the
+talloc library can be used directly in functions that do not use talloc
+internally. For example we can do the following:
+
+@code
+char *str1 = strdup("I am NOT a talloc context");
+char *str2 = talloc_strdup(NULL, "I AM a talloc context");
+
+printf("%d\n", strcmp(str1, str2) == 0);
+
+free(str1);
+talloc_free(str2); /* we can not use free() on str2 */
+@endcode
+
+This is possible because the context is internally handled as a special
+fixed-length structure called talloc chunk. Each chunk stores context metadata
+followed by the memory space requested by the programmer. When a talloc
+function returns a context (pointer), it will in fact return a pointer to the user
+space portion of the talloc chunk. If we to manipulate this context using
+talloc functions, the talloc library transforms the user-space pointer back to
+the starting address of the chunk. This is also the reason why we were unable
+to use <code>free(str2)</code> in the previous example - because
+<code>str2</code> does not point at the beginning of the allocated block of
+memory. This is illustrated on the next image:
+
+@image html context.png
+
+The type TALLOC_CTX is defined in talloc.h to identify a talloc context in
+function parameters. However, this type is just an alias for <code>void</code>
+and exists only for semantical reasons - thus we can differentiate between
+<code>void *</code> (arbitrary data) and <code>TALLOC_CTX *</code> (talloc
+context).
+
+@subsection metadata Context meta data
+
+Every talloc context carries several pieces of internal information along with
+the allocated memory:
+
+  - name - which is used in reports of context hierarchy and to simulate
+    a dynamic type system,
+  - size of the requested memory in bytes - this can be used to determine
+    the number of elements in arrays,
+  - attached destructor - which is executed just before the memory block is
+    about to be freed,
+  - references to the context
+  - children and parent contexts - create the hierarchical view on the
+    memory.
+
+@section context-hierarchy Hierarchy of talloc context
+
+Every talloc context contains information about its parent and children. Talloc
+uses this information to create a hierarchical model of memory or to be more
+precise, it creates an n-ary tree where each node represents a single talloc
+context. The root node of the tree is referred to as a top level context - a
+context without any parent.
+
+This approach has several advantages:
+
+  - as a consequence of freeing a talloc context, all of its children
+    will be properly deallocated as well,
+  - the parent of a context can be changed at any time, which
+    results in moving the whole subtree under another node,
+  - it creates a more natural way of managing data structures.
+
+@subsection Example
+
+We have a structure that stores basic information about a user - his/her name,
+identification number and groups he/she is a member of:
+
+@code
+struct user {
+  uid_t uid;
+  char *username;
+  size_t num_groups;
+  char **groups;
+};
+@endcode
+
+We will allocate this structure using talloc. The result will be the following
+context tree:
+
+@image html context_tree.png
+
+@code
+/* create new top level context */
+struct user *user = talloc(NULL, struct user);
+
+user->uid = 1000;
+user->num_groups = N;
+
+/* make user the parent of following contexts */
+user->username = talloc_strdup(user, "Test user");
+user->groups = talloc_array(user, char*, user->num_groups);
+
+for (i = 0; i < user->num_groups; i++) {
+  /* make user->groups the parent of following context */
+  user->groups[i] = talloc_asprintf(user->groups,
+                                    "Test group %d", i);
+}
+@endcode
+
+This way, we have gained a lot of additional capabilities, one of which is
+very simple deallocation of the structure and all of its elements.
+
+With the C standard library we need first to iterate over the array of groups
+and free every element separately. Then we must deallocate the array that stores
+them. Next we deallocate the username and as the last step free the structure
+itself. But with talloc, the only operation we need to execute is freeing the
+structure context. Its descendants will be freed automatically.
+
+@code
+talloc_free(user);
+@endcode
+
+@section keep-hierarchy Always keep the hieararchy steady!
+
+The talloc is a hierarchy memory allocator. The hierarchy nature is what makes
+the programming more error proof. It makes the memory easier to manage and to
+free.  Therefore, the first thing we should have on our mind is: <strong>always
+project our data structures into the talloc context hierarchy</strong>.
+
+That means if we have a structure, we should always use it as a parent context
+for its elements. This way we will not encounter any troubles when freeing this
+structure or when changing its parent. The same rule applies for arrays.
+
+@section creating-context Creating a talloc context
+
+Here are the most important functions that create a new talloc context.
+
+@subsection type-safe Type-safe functions
+
+It allocates the size that is necessary for the given type and returns a new,
+properly-casted pointer. This is the preferred way to create a new context as
+we can rely on the compiler to detect type mismatches.
+
+The name of the context is automatically set to the name of the data type which
+is used to simulate a dynamic type system.
+
+@code
+struct user *user = talloc(ctx, struct user);
+
+/* initialize to default values */
+user->uid = 0;
+user->name = NULL;
+user->num_groups = 0;
+user->groups = NULL;
+
+/* or we can achieve the same result with */
+struct user *user_zero = talloc_zero(ctx, struct user);
+@endcode
+
+@subsection zero-length Zero-length contexts
+
+The zero-length context is basically a context without any special semantical
+meaning. We can use it the same way as any other context. The only difference
+is that it consists only of the meta data about the context. Therefore, it is
+strictly of type <code>TALLOC_CTX*</code>. It is often used in cases where we
+want to aggregate several data structures under one parent (zero-length)
+context, such as a temporary context to contain memory needed within a single
+function that is not interesting to the caller. Allocating on a zero-length
+temporary context will make clean-up of the function simpler.
+
+@code
+TALLOC_CTX *tmp_ctx = NULL;
+struct foo *foo = NULL;
+struct bar *bar = NULL;
+
+/* new zero-length top level context */
+tmp_ctx = talloc_new(NULL);
+if (tmp_ctx == NULL) {
+  return ENOMEM;
+}
+
+foo = talloc(tmp_ctx, struct foo);
+bar = talloc(tmp_ctx, struct bar);
+
+/* free everything at once */
+talloc_free(tmp_ctx);
+@endcode
+
+@subsection context-see-also See also
+
+- talloc_size()
+- talloc_named()
+- @ref talloc_array
+- @ref talloc_string
+
+*/
diff --git a/doc/tutorial_debugging.dox b/doc/tutorial_debugging.dox
new file mode 100644 (file)
index 0000000..aadbb0d
--- /dev/null
@@ -0,0 +1,116 @@
+/**
+@page libtalloc_debugging Chapter 6: Debugging
+
+Although talloc makes memory management significantly easier than the C standard
+library, developers are still only humans and can make mistakes. Therefore, it
+can be handy to know some tools for the inspection of talloc memory usage.
+
+@section log-abort Talloc log and abort
+
+We have already encountered the abort function in section @ref dts.
+In that case it was used when a type mismatch was detected. However, talloc
+calls this abort function in several more situations:
+
+- when the provided pointer is not a valid talloc context,
+- when the meta data is invalid - probably due to memory corruption,
+- and when an access after free is detected.
+
+The third one is probably the most interesting. It can help us with detecting
+an attempt to double-free a context or any other manipulation with it via
+talloc functions (using it as a parent, stealing it, etc.).
+
+Before the context is freed talloc sets a flag in the meta data. This is then
+used to detect the access after free. It basically works on the assumption that
+the memory stays unchanged (at least for a while) even when it is properly
+deallocated. This will work even if the memory is filled with the value
+specified in <code>TALLOC_FREE_FILL</code> environment variable, because it
+fills only the data part and leaves the meta data intact.
+
+Apart from the abort function, talloc uses a log function to provide additional
+information to the aforementioned violations. To enable logging we shall set the
+log function with one of:
+
+- talloc_set_log_fn()
+- talloc_set_log_stderr()
+
+The following code is a sample output of accessing a context after it has been
+freed:
+
+@code
+talloc_set_log_stderr();
+TALLOC_CTX *ctx = talloc_new(NULL);
+
+talloc_free(ctx);
+talloc_free(ctx);
+
+results in:
+talloc: access after free error - first free may be at ../src/main.c:55
+Bad talloc magic value - access after free
+@endcode
+
+Another example is an invalid context:
+
+@code
+talloc_set_log_stderr();
+TALLOC_CTX *ctx = talloc_new(NULL);
+char *str = strdup("not a talloc context");
+talloc_steal(ctx, str);
+
+results in:
+Bad talloc magic value - unknown value
+@endcode
+
+@section reports Memory usage reports
+
+Talloc can print reports of memory usage of a specified talloc context to a
+file (to <code>stdout</code> or <code>stderr</code>). The report can be
+simple or full. The simple report provides information only about the context
+itself and its direct descendants. The full report goes recursively through the
+entire context tree. See:
+
+- talloc_report()
+- talloc_report_full()
+
+We will use the following code to retrieve the sample report:
+
+@code
+struct foo {
+  char *str;
+};
+
+TALLOC_CTX *ctx = talloc_new(NULL);
+char *str =  talloc_strdup(ctx, "my string");
+struct foo *foo = talloc_zero(ctx, struct foo);
+foo->str = talloc_strdup(foo, "I am Foo");
+char *str2 = talloc_strdup(foo, "Foo is my parent");
+
+/* print full report */
+talloc_report_full(ctx, stdout);
+@endcode
+
+It will print a full report of <code>ctx</code> to the standard output.
+The message should be similar to:
+
+@code
+full talloc report on 'talloc_new: ../src/main.c:82' (total 46 bytes in 5 blocks)
+  struct foo contains 34 bytes in 3 blocks (ref 0) 0x1495130
+    Foo is my parent contains 17 bytes in 1 blocks (ref 0) 0x1495200
+    I am Foo contains 9 bytes in 1 blocks (ref 0) 0x1495190
+  my string contains 10 bytes in 1 blocks (ref 0) 0x14950c0
+@endcode
+
+We can notice in this report that something is wrong with the context containing
+<code>struct foo</code>. We know that the structure has only one string element.
+However, we can see in the report that it has two children. This indicates that
+we have either violated the memory hierarchy or forgotten to free it as
+temporary data. Looking into the code, we can see that <code>"Foo is my parent"
+</code> should be attached to <code>ctx</code>.
+
+See also:
+
+- talloc_enable_null_tracking()
+- talloc_disable_null_tracking()
+- talloc_enable_leak_report()
+- talloc_enable_leak_report_full()
+
+*/
diff --git a/doc/tutorial_destructors.dox b/doc/tutorial_destructors.dox
new file mode 100644 (file)
index 0000000..ed06387
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+@page libtalloc_destructors Chapter 4: Using destructors
+
+@section destructors Using destructors
+
+Destructors are well known methods in the world of object oriented programming.
+A destructor is a method of an object that is automatically run when the object
+is destroyed. It is usually used to return resources taken by the object back to
+the system (e.g. closing file descriptors, terminating connection to a database,
+deallocating memory).
+
+With talloc we can take the advantage of destructors even in C. We can easily
+attach our own destructor to a talloc context. When the context is freed, the
+destructor will run automatically.
+
+To attach/detach a destructor to a talloc context use: talloc_set_destructor().
+
+@section destructors-example Example
+
+Imagine that we have a dynamically created linked list. Before we deallocate an
+element of the list, we need to make sure that we have successfully removed it
+from the list. Normally, this would be done by two commands in the exact order:
+remove it from the list and then free the element. With talloc, we can do this
+at once by setting a destructor on the element which will remove it from the
+list and talloc_free() will do the rest.
+
+The destructor would be:
+
+@code
+int list_remove(void *ctx)
+{
+    struct list_el *el = NULL;
+    el = talloc_get_type_abort(ctx, struct list_el);
+    /* remove element from the list */
+}
+@endcode
+
+GCC version 3 and newer can check for the types during the compilation. So if
+it is our major compiler, we can use a more advanced destructor:
+
+@code
+int list_remove(struct list_el *el)
+{
+    /* remove element from the list */
+}
+@endcode
+
+Now we will assign the destructor to the list element. We can do this directly
+in the function that inserts it.
+
+@code
+struct list_el* list_insert(TALLOC_CTX *mem_ctx,
+                            struct list_el *where,
+                            void *ptr)
+{
+  struct list_el *el = talloc(mem_ctx, struct list_el);
+  el->data = ptr;
+  /* insert into list */
+
+  talloc_set_destructor(el, list_remove);
+  return el;
+}
+@endcode
+
+Because talloc is a hierarchical memory allocator, we can go a step further and
+free the data with the element as well:
+
+@code
+struct list_el* list_insert_free(TALLOC_CTX *mem_ctx,
+                                 struct list_el *where,
+                                 void *ptr)
+{
+  struct list_el *el = NULL;
+  el = list_insert(mem_ctx, where, ptr);
+
+  talloc_steal(el, ptr);
+
+  return el;
+}
+@endcode
+
+*/
diff --git a/doc/tutorial_dts.dox b/doc/tutorial_dts.dox
new file mode 100644 (file)
index 0000000..75b5172
--- /dev/null
@@ -0,0 +1,109 @@
+/**
+@page libtalloc_dts Chapter 3: Dynamic type system
+
+@section dts Dynamic type system
+
+Generic programming in the C language is very difficult. There is no inheritance
+nor templates known from object oriented languages. There is no dynamic type
+system. Therefore, generic programming in this language is usually done by
+type-casting a variable to <code>void*</code> and transferring it through
+a generic function to a specialized callback as illustrated on the next listing.
+
+@code
+void generic_function(callback_fn cb, void *pvt)
+{
+  /* do some stuff and call the callback */
+  cb(pvt);
+}
+
+void specific_callback(void *pvt)
+{
+  struct specific_struct *data;
+  data = (struct specific_struct*)pvt;
+  /* ... */
+}
+
+void specific_function()
+{
+  struct specific_struct data;
+  generic_function(callback, &data);
+}
+@endcode
+
+Unfortunately, the type information is lost as a result of this type cast. The
+compiler cannot check the type during the compilation nor are we able to do it
+at runtime. Providing an invalid data type to the callback will result in
+unexpected behaviour (not necessarily a crash) of the application. This mistake
+is usually hard to detect because it is not the first thing which comes the
+mind.
+
+As we already know, every talloc context contains a name. This name is available
+at any time and it can be used to determine the type of a context even if we
+lose the type of a variable.
+
+Although the name of the context can be set to any arbitrary string, the best
+way of using it to simulate the dynamic type system is to set it directly to the
+type of the variable.
+
+It is recommended to use one of talloc() and talloc_array() (or its
+variants) to create the context as they set its name to the name of the
+given type automatically.
+
+If we have a context with such as a name, we can use two similar functions that
+do both the type check and the type cast for us:
+
+- talloc_get_type()
+- talloc_get_type_abort()
+
+@section dts-examples Examples
+
+The following example will show how generic programming with talloc is handled -
+if we provide invalid data to the callback, the program will be aborted. This
+is a sufficient reaction for such an error in most applications.
+
+@code
+void foo_callback(void *pvt)
+{
+  struct foo *data = talloc_get_type_abort(pvt, struct foo);
+  /* ... */
+}
+
+int do_foo()
+{
+  struct foo *data = talloc_zero(NULL, struct foo);
+  /* ... */
+  return generic_function(foo_callback, data);
+}
+@endcode
+
+But what if we are creating a service application that should be running for the
+uptime of a server, we may want to abort the application during the development
+process (to make sure the error is not overlooked) and try to recover from the
+error in the customer release. This can be achieved by creating a custom abort
+function with a conditional build.
+
+@code
+void my_abort(const char *reason)
+{
+  fprintf(stderr, "talloc abort: %s\n", reason);
+#ifdef ABORT_ON_TYPE_MISMATCH
+  abort();
+#endif
+}
+@endcode
+
+The usage of talloc_get_type_abort() would be then:
+
+@code
+talloc_set_abort_fn(my_abort);
+
+TALLOC_CTX *ctx = talloc_new(NULL);
+char *str = talloc_get_type_abort(ctx, char);
+if (str == NULL) {
+  /* recovery code */
+}
+/* talloc abort: ../src/main.c:25: Type mismatch:
+   name[talloc_new: ../src/main.c:24] expected[char] */
+@endcode
+
+*/
diff --git a/doc/tutorial_introduction.dox b/doc/tutorial_introduction.dox
new file mode 100644 (file)
index 0000000..02777b9
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+@page libtalloc_tutorial The Tutorial
+@section introduction Introduction
+
+Talloc is a hierarchical, reference counted memory pool system with destructors.
+It is built atop the C standard library and it defines a set of utility
+functions that altogether simplifies allocation and deallocation of data,
+especially for complex structures that contain many dynamically allocated
+elements such as strings and arrays.
+
+The main goals of this library are: removing the needs for creating a cleanup
+function for every complex structure, providing a logical organization of
+allocated memory blocks and reducing the likelihood of creating memory leaks in
+long-running applications. All of this is achieved by allocating memory in a
+hierarchical structure of talloc contexts such that deallocating one context
+recursively frees all of its descendants as well.
+
+@section main-features Main features
+- An open source project
+- A hierarchical memory model
+- Natural projection of data structures into the memory space
+- Simplifies memory management of large data structures
+- Automatic execution of a destructor before the memory is freed
+- Simulates a dynamic type system
+- Implements a transparent memory pool
+
+@section toc Table of contents:
+
+@subpage libtalloc_context
+
+@subpage libtalloc_stealing
+
+@subpage libtalloc_dts
+
+@subpage libtalloc_destructors
+
+@subpage libtalloc_pools
+
+@subpage libtalloc_debugging
+
+@subpage libtalloc_bestpractices
+
+*/
\ No newline at end of file
diff --git a/doc/tutorial_pools.dox b/doc/tutorial_pools.dox
new file mode 100644 (file)
index 0000000..a0d1e1a
--- /dev/null
@@ -0,0 +1,93 @@
+/**
+@page libtalloc_pools Chapter 5: Memory pools
+
+@section pools Memory pools
+
+Allocation of a new memory is an expensive operation and large programs can
+contain thousands of calls of malloc() for a single computation, where every
+call allocates only a very small amount of the memory. This can result in an
+undesirable slowdown of the application. We can avoid this slowdown by
+decreasing the number of malloc() calls by using a memory pool.
+
+A memory pool is a preallocated memory space with a fixed size. If we need to
+allocate new data we will take the desired amount of the memory from the pool
+instead of requesting a new memory from the system. This is done by creating a
+pointer that points inside the preallocated memory. Such a pool must not be
+reallocated as it would change its location - pointers that were pointing
+inside the pool would become invalid. Therefore, a memory pool requires a very
+good estimate of the required memory space.
+
+The talloc library contains its own implementation of a memory pool. It is
+highly transparent for the programmer. The only thing that needs to be done is
+an initialization of a new pool context using talloc_pool() -
+which can be used in the same way as any other context.
+
+Refactoring of existing code (that uses talloc) to take the advantage of a
+memory pool is quite simple due to the following properties of the pool context:
+
+- if we are allocating data on a pool context, it takes the desired
+  amount of memory from the pool,
+- if the context is a descendant of the pool context, it takes the space
+  from the pool as well,
+- if the pool does not have sufficient portion of memory left, it will
+  create a new non-pool context, leaving the pool intact
+
+@code
+/* allocate 1KiB in a pool */
+TALLOC_CTX *pool_ctx = talloc_pool(NULL, 1024);
+
+/* Take 512B from the pool, 512B is left there */
+void *ptr = talloc_size(pool_ctx, 512);
+
+/* 1024B > 512B, this will create new talloc chunk outside
+   the pool */
+void *ptr2 = talloc_size(ptr, 1024);
+
+/* The pool still contains 512 free bytes
+ * this will take 200B from them. */
+void *ptr3 = talloc_size(ptr, 200);
+
+/* This will destroy context 'ptr3' but the memory
+ * is not freed, the available space in the pool
+ * will increase to 512B. */
+talloc_free(ptr3);
+
+/* This will free memory taken by 'pool_ctx'
+ * and 'ptr2' as well. */
+talloc_free(pool_ctx);
+@endcode
+
+The above given is very convenient, but there is one big issue to be kept in
+mind. If the parent of a talloc pool child is changed to a parent that is
+outside of this pool, the whole pool memory will not be freed until the child is
+freed. For this reason we must be very careful when stealing a descendant of a
+pool context.
+
+@code
+TALLOC_CTX *mem_ctx = talloc_new(NULL);
+TALLOC_CTX *pool_ctx = talloc_pool(NULL, 1024);
+struct foo *foo = talloc(pool_ctx, struct foo);
+
+/* mem_ctx is not in the pool */
+talloc_steal(mem_ctx, foo);
+
+/* pool_ctx is marked as freed but the memory is not
+   deallocated, accessing the pool_ctx again will cause
+   an error */
+talloc_free(pool_ctx);
+
+/* This deallocates the pool_ctx. */
+talloc_free(mem_ctx);
+@endcode
+
+It may often be better to copy the memory we want instead of stealing it to
+avoid this problem. If we do not need to retain the context name (to keep the
+type information), we can use talloc_memdup() to do this.
+
+Copying the memory out of the pool may, however, discard all the performance
+boost given by the pool, depending on the size of the copied memory. Therefore,
+the code should be well profiled before taking this path. In general, the
+golden rule is: if we need to steal from the pool context, we should not
+use a pool context.
+
+*/
diff --git a/doc/tutorial_stealing.dox b/doc/tutorial_stealing.dox
new file mode 100644 (file)
index 0000000..67eae1d
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+@page libtalloc_stealing Chapter 2: Stealing a context
+
+@section stealing Stealing a context
+
+Talloc has the ability to change the parent of a talloc context to another
+one. This operation is commonly referred to as stealing and it is one of
+the most important actions performed with talloc contexts.
+
+Stealing a context is necessary if we want the pointer to outlive the context it
+is created on. This has many possible use cases, for instance stealing a result
+of a database search to an in-memory cache context, changing the parent of a
+field of a generic structure to a more specific one or vice-versa. The most
+common scenario, at least in Samba, is to steal output data from a function-specific
+context to the output context given as an argument of that function.
+
+@code
+struct foo {
+    char *a1;
+    char *a2;
+    char *a3;
+};
+
+struct bar {
+    char *wurst;
+    struct foo *foo;
+};
+
+struct foo *foo = talloc_zero(ctx, struct foo);
+foo->a1 = talloc_strdup(foo, "a1");
+foo->a2 = talloc_strdup(foo, "a2");
+foo->a3 = talloc_strdup(foo, "a3");
+
+struct bar *bar = talloc_zero(NULL, struct bar);
+/* change parent of foo from ctx to bar */
+bar->foo = talloc_steal(bar, foo);
+
+/* or do the same but assign foo = NULL */
+bar->foo = talloc_move(bar, &foo);
+@endcode
+
+The talloc_move() function is similar to the talloc_steal() function but
+additionally sets the source pointer to NULL.
+
+In general, the source pointer itself is not changed (it only replaces the
+parent in the meta data). But the common usage is that the result is
+assigned to another variable, thus further accessing the pointer from the
+original variable should be avoided unless it is necessary. In this case
+talloc_move() is the preferred way of stealing a context. Additionally sets the
+source pointer to NULL, thus.protects the pointer from being accidentally freed
+and accessed using the old variable after its parent has been changed.
+
+@image html stealing.png
+
+*/
index 5e3a3197bac4528d46cc549bfa112f5c57b031b1..0e27d6129951cbe19e6d13ab83730718d47e6980 100644 (file)
@@ -1,14 +1,14 @@
-# Doxyfile 1.6.1
+# Doxyfile 1.8.0
 
 # This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
+# doxygen (www.doxygen.org) for a project.
 #
-# All text after a hash (#) is considered a comment and will be ignored
+# All text after a hash (#) is considered a comment and will be ignored.
 # The format is:
 #       TAG = value [value, ...]
 # For lists items can also be appended using:
 #       TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
+# Values that contain spaces should be placed between quotes (" ").
 
 #---------------------------------------------------------------------------
 # Project related configuration options
@@ -22,8 +22,9 @@
 
 DOXYFILE_ENCODING      = UTF-8
 
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
 
 PROJECT_NAME           = talloc
 
@@ -33,6 +34,19 @@ PROJECT_NAME           = talloc
 
 PROJECT_NUMBER         = 2.0
 
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          =
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO           =
+
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
 # base path where the generated documentation will be put.
 # If a relative path is entered, it will be relative to the location
@@ -57,7 +71,7 @@ CREATE_SUBDIRS         = NO
 # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
 # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
 # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
 # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
 
 OUTPUT_LANGUAGE        = English
@@ -136,7 +150,7 @@ STRIP_FROM_PATH        =
 STRIP_FROM_INC_PATH    =
 
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
+# (but less readable) file names. This can be useful if your file system
 # doesn't support long names like on DOS, Mac, or CD-ROM.
 
 SHORT_NAMES            = NO
@@ -191,6 +205,13 @@ TAB_SIZE               = 8
 
 ALIASES                =
 
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding
+# "class=itcl::class" will allow you to use the command class in the
+# itcl::class meaning.
+
+TCL_SUBST              =
+
 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
 # sources only. Doxygen will then generate output that is more tailored for C.
 # For instance, some of the names that are used will be different. The list
@@ -217,22 +238,32 @@ OPTIMIZE_FOR_FORTRAN   = NO
 
 OPTIMIZE_OUTPUT_VHDL   = NO
 
-# Doxygen selects the parser to use depending on the extension of the files it parses.
-# With this tag you can assign which parser to use for a given extension.
-# Doxygen has a built-in mapping, but you can override or extend it using this tag.
-# The format is ext=language, where ext is a file extension, and language is one of
-# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
-# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
-# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
-# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
 
 EXTENSION_MAPPING      =
 
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
+# comments according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you
+# can mix doxygen, HTML, and XML commands with Markdown formatting.
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT       = YES
+
 # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
 # to include (a tag file for) the STL sources as input, then you should
 # set this tag to YES in order to let doxygen match functions declarations and
 # definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also make the inheritance and collaboration
+# func(std::string) {}). This also makes the inheritance and collaboration
 # diagrams that involve STL classes more complete and accurate.
 
 BUILTIN_STL_SUPPORT    = NO
@@ -250,7 +281,7 @@ SIP_SUPPORT            = NO
 
 # For Microsoft's IDL there are propget and propput attributes to indicate getter
 # and setter methods for a property. Setting this option to YES (the default)
-# will make doxygen to replace the get and set methods by a property in the
+# will make doxygen replace the get and set methods by a property in the
 # documentation. This will only work if the methods are indeed getting or
 # setting a simple type. If this is not the case, or you want to show the
 # methods anyway, you should set this option to NO.
@@ -272,6 +303,22 @@ DISTRIBUTE_GROUP_DOC   = NO
 
 SUBGROUPING            = YES
 
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields will be shown inline in the documentation
+# of the scope in which they are defined (i.e. file, namespace, or group
+# documentation), provided this scope is documented. If set to NO (the default),
+# structs, classes, and unions are shown on a separate page (for HTML and Man
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS  = NO
+
 # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
 # is documented as struct, union, or enum with the name of the typedef. So
 # typedef struct TypeS {} TypeT, will appear in the documentation as a struct
@@ -288,16 +335,27 @@ TYPEDEF_HIDES_STRUCT   = NO
 # For small to medium size projects (<1000 input files) the default value is
 # probably good enough. For larger projects a too small cache size can cause
 # doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penality.
+# causing a significant performance penalty.
 # If the system has enough physical memory increasing the cache will improve the
 # performance by keeping more symbols in memory. Note that the value works on
-# a logarithmic scale so increasing the size by one will rougly double the
+# a logarithmic scale so increasing the size by one will roughly double the
 # memory usage. The cache size is given by this formula:
 # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols
+# corresponding to a cache size of 2^16 = 65536 symbols.
 
 SYMBOL_CACHE_SIZE      = 0
 
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
+# their name and scope. Since this can be an expensive process and often the
+# same symbol appear multiple times in the code, doxygen keeps a cache of
+# pre-resolved symbols. If the cache is too small doxygen will become slower.
+# If the cache is too large, memory is wasted. The cache size is given by this
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE      = 0
+
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
@@ -314,6 +372,10 @@ EXTRACT_ALL            = NO
 
 EXTRACT_PRIVATE        = NO
 
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation.
+
+EXTRACT_PACKAGE        = NO
+
 # If the EXTRACT_STATIC tag is set to YES all static members of a file
 # will be included in the documentation.
 
@@ -336,7 +398,7 @@ EXTRACT_LOCAL_METHODS  = NO
 # extracted and appear in the documentation as a namespace called
 # 'anonymous_namespace{file}', where file will be replaced with the base
 # name of the file that contains the anonymous namespace. By default
-# anonymous namespace are hidden.
+# anonymous namespaces are hidden.
 
 EXTRACT_ANON_NSPACES   = NO
 
@@ -396,6 +458,12 @@ HIDE_SCOPE_NAMES       = NO
 
 SHOW_INCLUDE_FILES     = YES
 
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
 # If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
 # is inserted in the documentation for inline members.
 
@@ -415,7 +483,13 @@ SORT_MEMBER_DOCS       = YES
 
 SORT_BRIEF_DOCS        = NO
 
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
 
 SORT_MEMBERS_CTORS_1ST = NO
 
@@ -435,6 +509,15 @@ SORT_GROUP_NAMES       = NO
 
 SORT_BY_SCOPE_NAME     = NO
 
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING  = NO
+
 # The GENERATE_TODOLIST tag can be used to enable (YES) or
 # disable (NO) the todo list. This list is created by putting \todo
 # commands in the documentation.
@@ -465,10 +548,10 @@ GENERATE_DEPRECATEDLIST= YES
 ENABLED_SECTIONS       =
 
 # The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
+# the initial value of a variable or macro consists of for it to appear in
 # the documentation. If the initializer consists of more lines than specified
 # here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
+# The appearance of the initializer of individual variables and macros in the
 # documentation can be controlled using \showinitializer or \hideinitializer
 # command in the documentation regardless of this setting.
 
@@ -480,12 +563,6 @@ MAX_INITIALIZER_LINES  = 30
 
 SHOW_USED_FILES        = YES
 
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES       = NO
-
 # Set the SHOW_FILES tag to NO to disable the generation of the Files page.
 # This will remove the Files entry from the Quick Index and from the
 # Folder Tree View (if specified). The default is YES.
@@ -509,15 +586,25 @@ SHOW_NAMESPACES        = YES
 
 FILE_VERSION_FILTER    =
 
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
-# doxygen. The layout file controls the global structure of the generated output files
-# in an output format independent way. The create the layout file that represents
-# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
-# file name after the option, if omitted DoxygenLayout.xml will be used as the name
-# of the layout file.
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. The create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
 
 LAYOUT_FILE            =
 
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES         =
+
 #---------------------------------------------------------------------------
 # configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
@@ -546,7 +633,7 @@ WARN_IF_UNDOCUMENTED   = YES
 
 WARN_IF_DOC_ERROR      = YES
 
-# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
 # functions that are documented, but have no documentation for their parameters
 # or return value. If set to NO (the default) doxygen will only warn about
 # wrong or incomplete parameter documentation, but not about the absence of
@@ -578,7 +665,8 @@ WARN_LOGFILE           =
 # directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
-INPUT                  = . doc
+INPUT                  = . \
+                         doc
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -592,8 +680,9 @@ INPUT_ENCODING         = UTF-8
 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
 # and *.h) to filter out the source-files in the directories. If left
 # blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
 
 FILE_PATTERNS          = *.cpp \
                          *.cc \
@@ -609,14 +698,16 @@ FILE_PATTERNS          = *.cpp \
 
 RECURSIVE              = NO
 
-# The EXCLUDE tag can be used to specify files and/or directories that should
+# The EXCLUDE tag can be used to specify files and/or directories that should be
 # excluded from the INPUT source files. This way you can easily exclude a
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
 
 EXCLUDE                =
 
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
 # from the input.
 
 EXCLUDE_SYMLINKS       = NO
@@ -627,10 +718,7 @@ EXCLUDE_SYMLINKS       = NO
 # against the file with absolute path, so to exclude all test directories
 # for example use the pattern */test/*
 
-EXCLUDE_PATTERNS       = */.git/* \
-                         */.svn/* \
-                         */cmake/* \
-                         */build/*
+EXCLUDE_PATTERNS       = */.git/*
 
 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
 # (namespaces, classes, functions, etc.) that should be excluded from the
@@ -664,7 +752,7 @@ EXAMPLE_RECURSIVE      = NO
 # directories that contain image that are included in the documentation (see
 # the \image command).
 
-IMAGE_PATH             =
+IMAGE_PATH             = doc
 
 # The INPUT_FILTER tag can be used to specify a program that doxygen should
 # invoke to filter for each input file. Doxygen will invoke the filter program
@@ -683,8 +771,8 @@ INPUT_FILTER           =
 # filter if there is a match.
 # The filters are a list of the form:
 # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
 
 FILTER_PATTERNS        =
 
@@ -694,6 +782,14 @@ FILTER_PATTERNS        =
 
 FILTER_SOURCE_FILES    = NO
 
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
 #---------------------------------------------------------------------------
 # configuration options related to source browsing
 #---------------------------------------------------------------------------
@@ -782,11 +878,6 @@ IGNORE_PREFIX          =
 
 GENERATE_HTML          = YES
 
-# If the HTML_FOOTER_DESCRIPTION tag is set to YES, Doxygen will
-# add generated date, project name and doxygen version to HTML footer.
-
-HTML_FOOTER_DESCRIPTION= NO
-
 # The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `html' will be used as the default path.
@@ -801,7 +892,14 @@ HTML_FILE_EXTENSION    = .html
 
 # The HTML_HEADER tag can be used to specify a personal HTML header for
 # each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
+# standard header. Note that when using a custom header you are responsible
+#  for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is advised to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
 
 HTML_HEADER            =
 
@@ -816,10 +914,50 @@ HTML_FOOTER            =
 # fine-tune the look of the HTML output. If the tag is left blank doxygen
 # will generate a default style sheet. Note that doxygen will try to copy
 # the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
+# style sheet in the HTML output directory as well, or it will be erased!
 
 HTML_STYLESHEET        =
 
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES       =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the style sheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = NO
+
 # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
 # files or namespaces will be aligned in HTML using tables. If set to
 # NO a bullet list will be used.
@@ -842,7 +980,8 @@ HTML_DYNAMIC_SECTIONS  = NO
 # directory and running "make install" will install the docset in
 # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
 # it at startup.
-# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
 
 GENERATE_DOCSET        = NO
 
@@ -860,6 +999,16 @@ DOCSET_FEEDNAME        = "Doxygen generated docs"
 
 DOCSET_BUNDLE_ID       = org.doxygen.Project
 
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
 # If the GENERATE_HTMLHELP tag is set to YES, additional index files
 # will be generated that can be used as input for tools like the
 # Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
@@ -904,10 +1053,10 @@ BINARY_TOC             = NO
 
 TOC_EXPAND             = NO
 
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
-# are set, an additional index file will be generated that can be used as input for
-# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
-# HTML documentation.
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
 
 GENERATE_QHP           = NO
 
@@ -929,20 +1078,24 @@ QHP_NAMESPACE          =
 
 QHP_VIRTUAL_FOLDER     = doc
 
-# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
-# For more information please see
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
 # http://doc.trolltech.com/qthelpproject.html#custom-filters
 
 QHP_CUST_FILTER_NAME   =
 
-# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
-# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
+# Qt Help Project / Custom Filters</a>.
 
 QHP_CUST_FILTER_ATTRS  =
 
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
 # filter section matches.
-# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
+# Qt Help Project / Filter Attributes</a>.
 
 QHP_SECT_FILTER_ATTRS  =
 
@@ -953,16 +1106,30 @@ QHP_SECT_FILTER_ATTRS  =
 
 QHG_LOCATION           =
 
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+#  will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
 
-DISABLE_INDEX          = NO
+GENERATE_ECLIPSEHELP   = NO
 
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
 
-ENUM_VALUES_PER_LINE   = 4
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
+# at top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it. Since the tabs have the same information as the
+# navigation tree you can set this option to NO if you already set
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX          = NO
 
 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
 # structure should be generated to display hierarchical information.
@@ -971,13 +1138,17 @@ ENUM_VALUES_PER_LINE   = 4
 # is generated for HTML Help). For this to work a browser that supports
 # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
 # Windows users are probably better off using the HTML help feature.
+# Since the tree basically has the same information as the tab index you
+# could consider to set DISABLE_INDEX to NO when enabling this option.
 
 GENERATE_TREEVIEW      = NONE
 
-# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
-# and Class Hierarchy pages using a tree view instead of an ordered list.
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
 
-USE_INLINE_TREES       = NO
+ENUM_VALUES_PER_LINE   = 4
 
 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
 # used to set the initial width (in pixels) of the frame in which the tree
@@ -985,6 +1156,11 @@ USE_INLINE_TREES       = NO
 
 TREEVIEW_WIDTH         = 250
 
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW    = NO
+
 # Use this tag to change the font size of Latex formulas included
 # as images in the HTML documentation. The default is 10. Note that
 # when you change the font size after a successful doxygen run you need
@@ -993,13 +1169,60 @@ TREEVIEW_WIDTH         = 250
 
 FORMULA_FONTSIZE       = 10
 
-# When the SEARCHENGINE tag is enable doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
-# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP)
-# there is already a search function so this one should typically
-# be disabled.
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you may also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to
+# the MathJax Content Delivery Network so you can quickly see the result without
+# installing MathJax.
+# However, it is strongly recommended to install a local
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS     =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
 
 SEARCHENGINE           = NO
 
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvantages are that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
@@ -1017,6 +1240,9 @@ LATEX_OUTPUT           = latex
 
 # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
 # invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
 
 LATEX_CMD_NAME         = latex
 
@@ -1033,7 +1259,7 @@ MAKEINDEX_CMD_NAME     = makeindex
 COMPACT_LATEX          = NO
 
 # The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
+# by the printer. Possible values are: a4, letter, legal and
 # executive. If left blank a4wide will be used.
 
 PAPER_TYPE             = a4wide
@@ -1050,6 +1276,13 @@ EXTRA_PACKAGES         =
 
 LATEX_HEADER           =
 
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER           =
+
 # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
 # is prepared for conversion to pdf (using ps2pdf). The pdf file will
 # contain links (just like the HTML output) instead of page references
@@ -1076,10 +1309,19 @@ LATEX_BATCHMODE        = NO
 
 LATEX_HIDE_INDICES     = NO
 
-# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
 
 LATEX_SOURCE_CODE      = NO
 
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE        = plain
+
 #---------------------------------------------------------------------------
 # configuration options related to the RTF output
 #---------------------------------------------------------------------------
@@ -1111,7 +1353,7 @@ COMPACT_RTF            = NO
 
 RTF_HYPERLINKS         = NO
 
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# Load style sheet definitions from file. Syntax is similar to doxygen's
 # config file, i.e. a series of assignments. You only have to provide
 # replacements, missing definitions are set to their default value.
 
@@ -1256,7 +1498,7 @@ MACRO_EXPANSION        = YES
 EXPAND_ONLY_PREDEF     = YES
 
 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
 
 SEARCH_INCLUDES        = YES
 
@@ -1281,20 +1523,21 @@ INCLUDE_FILE_PATTERNS  =
 # undefined via #undef or recursively expanded use the := operator
 # instead of the = operator.
 
-PREDEFINED             = DOXYGEN PRINTF_ATTRIBUTE(x,y)=
+PREDEFINED             = DOXYGEN \
+                         PRINTF_ATTRIBUTE(x,y)=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
 # this tag can be used to specify a list of macro names that should be expanded.
 # The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
 
 EXPAND_AS_DEFINED      =
 
 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
 
 SKIP_FUNCTION_MACROS   = YES
 
@@ -1302,22 +1545,18 @@ SKIP_FUNCTION_MACROS   = YES
 # Configuration::additions related to external references
 #---------------------------------------------------------------------------
 
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
+# The TAGFILES option can be used to specify one or more tagfiles. For each
+# tag file the location of the external documentation should be added. The
+# format of a tag file without this location is as follows:
 #
 # TAGFILES = file1 file2 ...
 # Adding location for the tag files is done as follows:
 #
 # TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
+# where "loc1" and "loc2" can be relative or absolute paths
+# or URLs. Note that each tag file must have a unique name (where the name does
+# NOT include the path). If a tag file is not located in the directory in which
+# doxygen is run, you must also specify the path to the tagfile here.
 
 TAGFILES               =
 
@@ -1350,9 +1589,8 @@ PERL_PATH              = /usr/bin/perl
 # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
 # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
 # or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option is superseded by the HAVE_DOT option below. This is only a
-# fallback. It is recommended to install and use dot, since it yields more
-# powerful graphs.
+# this option also works with HAVE_DOT disabled, but it is recommended to
+# install and use dot, since it yields more powerful graphs.
 
 CLASS_DIAGRAMS         = YES
 
@@ -1378,14 +1616,20 @@ HIDE_UNDOC_RELATIONS   = YES
 
 HAVE_DOT               = NO
 
-# By default doxygen will write a font called FreeSans.ttf to the output
-# directory and reference it in all dot files that doxygen generates. This
-# font does not include all possible unicode characters however, so when you need
-# these (or just want a differently looking font) you can specify the font name
-# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
-# which can be done by putting it in a standard location or by setting the
-# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
-# containing the font.
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS        = 0
+
+# By default doxygen will use the Helvetica font for all dot files that
+# doxygen generates. When you want a differently looking font you can specify
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find
+# the font, which can be done by putting it in a standard location or by setting
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
+# directory containing the font.
 
 DOT_FONTNAME           = FreeSans
 
@@ -1394,17 +1638,16 @@ DOT_FONTNAME           = FreeSans
 
 DOT_FONTSIZE           = 10
 
-# By default doxygen will tell dot to use the output directory to look for the
-# FreeSans.ttf font (which doxygen will put there itself). If you specify a
-# different font using DOT_FONTNAME you can set the path where dot
-# can find it using this tag.
+# By default doxygen will tell dot to use the Helvetica font.
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
+# set the path where dot can find it.
 
 DOT_FONTPATH           =
 
 # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
 # will generate a graph for each documented class showing the direct and
 # indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
+# CLASS_DIAGRAMS tag to NO.
 
 CLASS_GRAPH            = YES
 
@@ -1426,6 +1669,15 @@ GROUP_GRAPHS           = YES
 
 UML_LOOK               = NO
 
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside
+# the class node. If there are many fields or methods and many nodes the
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
+# threshold limits the number of items for each type to make the size more
+# managable. Set this to 0 for no limit. Note that the threshold may be
+# exceeded by 50% before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS   = 10
+
 # If set to YES, the inheritance and collaboration graphs will show the
 # relations between templates and their instances.
 
@@ -1462,11 +1714,11 @@ CALL_GRAPH             = NO
 CALLER_GRAPH           = NO
 
 # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
+# will generate a graphical hierarchy of all classes instead of a textual one.
 
 GRAPHICAL_HIERARCHY    = YES
 
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
 # then doxygen will show the dependencies a directory has on other directories
 # in a graphical way. The dependency relations are determined by the #include
 # relations between the files in the directories.
@@ -1474,11 +1726,22 @@ GRAPHICAL_HIERARCHY    = YES
 DIRECTORY_GRAPH        = YES
 
 # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
+# generated by dot. Possible values are svg, png, jpg, or gif.
+# If left blank png will be used. If you choose svg you need to set
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible in IE 9+ (other browsers do not have this requirement).
 
 DOT_IMAGE_FORMAT       = png
 
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+# Note that this requires a modern browser other than Internet Explorer.
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG        = NO
+
 # The tag DOT_PATH can be used to specify the path where the dot tool can be
 # found. If left blank, it is assumed the dot tool can be found in the path.
 
@@ -1490,6 +1753,12 @@ DOT_PATH               =
 
 DOTFILE_DIRS           =
 
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the
+# \mscfile command).
+
+MSCFILE_DIRS           =
+
 # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
 # nodes that will be shown in the graph. If the number of nodes in a graph
 # becomes larger than this value, doxygen will truncate the graph, which is
diff --git a/lib/replace/Makefile.in b/lib/replace/Makefile.in
deleted file mode 100644 (file)
index 65f8125..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#!gmake
-#
-CC = @CC@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-includedir = @includedir@
-libdir = @libdir@
-VPATH = @libreplacedir@
-srcdir = @srcdir@
-builddir = @builddir@
-sharedbuilddir = @sharedbuilddir@
-INSTALLCMD = @INSTALL@
-LIBS = @LIBS@
-
-.PHONY: test all showflags install installcheck clean distclean realdistclean
-
-CFLAGS=-I. @CFLAGS@
-LDFLAGS=@LDFLAGS@
-
-OBJS = @LIBREPLACEOBJ@
-
-all: showflags libreplace.a testsuite
-
-showflags:
-       @echo 'libreplace will be compiled with flags:'
-       @echo '  CC     = $(CC)'
-       @echo '  CFLAGS = $(CFLAGS)'
-       @echo '  LDFLAGS= $(LDFLAGS)'
-       @echo '  LIBS   = $(LIBS)'
-
-install: all
-       ${INSTALLCMD} -d $(libdir)
-       ${INSTALLCMD} -m 644 libreplace.a $(libdir)
-
-shared-build: all
-       ${INSTALLCMD} -d $(sharedbuilddir)/include
-       ${INSTALLCMD} -m 644 replace.h $(sharedbuilddir)/include
-       ${INSTALLCMD} -d $(sharedbuilddir)/lib
-       ${INSTALLCMD} -m 644 libreplace.a $(sharedbuilddir)/lib
-
-libreplace.a: $(OBJS)
-       ar -rcsv $@ $(OBJS)
-
-test: all
-       ./testsuite
-
-installcheck: install test
-
-TEST_OBJS = test/main.o test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o
-
-testsuite: libreplace.a $(TEST_OBJS)
-       $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS)
-
-.c.o:
-       @echo Compiling $*.c
-       @mkdir -p `dirname $@`
-       @$(CC) $(CFLAGS) -c $< -o $@
-
-clean:
-       rm -f *.o test/*.o *.a testsuite
-       rm -f testfile.dat
-
-distclean: clean
-       rm -f *~ */*~
-       rm -f config.log config.status config.h config.cache
-       rm -f Makefile
-
-realdistclean: distclean
-       rm -f configure config.h.in
index bf4e67ff0c9911608111cec98d244d6997c6e670..e960dc877eae8ee18e7e2851a8a9af79c78cbbb7 100644 (file)
@@ -72,6 +72,8 @@ link
 readlink
 symlink
 realpath
+poll
+setproctitle
 
 Types:
 bool
@@ -80,6 +82,8 @@ uint{8,16,32,64}_t
 int{8,16,32,64}_t
 intptr_t
 sig_atomic_t
+blksize_t
+blkcnt_t
 
 Constants:
 PATH_NAME_MAX
diff --git a/lib/replace/aclocal.m4 b/lib/replace/aclocal.m4
deleted file mode 100644 (file)
index 5605e47..0000000
+++ /dev/null
@@ -1 +0,0 @@
-m4_include(libreplace.m4)
diff --git a/lib/replace/autoconf-2.60.m4 b/lib/replace/autoconf-2.60.m4
deleted file mode 100644 (file)
index b2694fd..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-# AC_GNU_SOURCE
-# --------------
-AC_DEFUN([AC_GNU_SOURCE],
-[AH_VERBATIM([_GNU_SOURCE],
-[/* Enable GNU extensions on systems that have them.  */
-#ifndef _GNU_SOURCE
-# undef _GNU_SOURCE
-#endif])dnl
-AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
-AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
-AC_DEFINE([_GNU_SOURCE])
-])
-
-# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
-#              ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
-# --------------------------------------------------------------
-# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
-# by trying to compile a program of TEST-PROLOGUE and TEST-BODY.  If this fails,
-# try again with each compiler option in the space-separated OPTION-LIST; if one
-# helps, append it to CC.  If eventually successful, run ACTION-IF-AVAILABLE,
-# else ACTION-IF-UNAVAILABLE.
-AC_DEFUN([_AC_C_STD_TRY],
-[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))
-AC_CACHE_VAL(ac_cv_prog_cc_$1,
-[ac_cv_prog_cc_$1=no
-ac_save_CC=$CC
-AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
-for ac_arg in '' $4
-do
-  CC="$ac_save_CC $ac_arg"
-  _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
-  test "x$ac_cv_prog_cc_$1" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-])# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_$1" in
-  x)
-    AC_MSG_RESULT([none needed]) ;;
-  xno)
-    AC_MSG_RESULT([unsupported]) ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_$1"
-    AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
-esac
-AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
-])# _AC_C_STD_TRY
-
-# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
-# ----------------------------------------------------------------
-# If the C compiler is not in ISO C99 mode by default, try to add an
-# option to output variable CC to make it so.  This macro tries
-# various options that select ISO C99 on some system or another.  It
-# considers the compiler to be in ISO C99 mode if it handles mixed
-# code and declarations, _Bool, inline and restrict.
-AC_DEFUN([_AC_PROG_CC_C99],
-[_AC_C_STD_TRY([c99],
-[[#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <stdio.h>
-
-struct incomplete_array
-{
-  int datasize;
-  double data[];
-};
-
-struct named_init {
-  int number;
-  const wchar_t *name;
-  double average;
-};
-
-typedef const char *ccp;
-
-static inline int
-test_restrict(ccp restrict text)
-{
-  // See if C++-style comments work.
-  // Iterate through items via the restricted pointer.
-  // Also check for declarations in for loops.
-  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
-    continue;
-  return 0;
-}
-
-// Check varargs and va_copy work.
-static void
-test_varargs(const char *format, ...)
-{
-  va_list args;
-  va_start(args, format);
-  va_list args_copy;
-  va_copy(args_copy, args);
-
-  const char *str;
-  int number;
-  float fnumber;
-
-  while (*format)
-    {
-      switch (*format++)
-       {
-       case 's': // string
-         str = va_arg(args_copy, const char *);
-         break;
-       case 'd': // int
-         number = va_arg(args_copy, int);
-         break;
-       case 'f': // float
-         fnumber = (float) va_arg(args_copy, double);
-         break;
-       default:
-         break;
-       }
-    }
-  va_end(args_copy);
-  va_end(args);
-}
-]],
-[[
-  // Check bool and long long datatypes.
-  _Bool success = false;
-  long long int bignum = -1234567890LL;
-  unsigned long long int ubignum = 1234567890uLL;
-
-  // Check restrict.
-  if (test_restrict("String literal") != 0)
-    success = true;
-  char *restrict newvar = "Another string";
-
-  // Check varargs.
-  test_varargs("s, d' f .", "string", 65, 34.234);
-
-  // Check incomplete arrays work.
-  struct incomplete_array *ia =
-    malloc(sizeof(struct incomplete_array) + (sizeof(double) * 10));
-  ia->datasize = 10;
-  for (int i = 0; i < ia->datasize; ++i)
-    ia->data[i] = (double) i * 1.234;
-
-  // Check named initialisers.
-  struct named_init ni = {
-    .number = 34,
-    .name = L"Test wide string",
-    .average = 543.34343,
-  };
-
-  ni.number = 58;
-
-  int dynamic_array[ni.number];
-  dynamic_array[43] = 543;
-
-  // work around unused variable warnings
-  return  bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x';
-]],
-dnl Try
-dnl GCC                -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
-dnl AIX                -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
-dnl Intel ICC  -c99
-dnl IRIX       -c99
-dnl Solaris    (unused because it causes the compiler to assume C99 semantics for
-dnl            library functions, and this is invalid before Solaris 10: -xc99)
-dnl Tru64      -c99
-dnl with extended modes being tried first.
-[[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl
-])# _AC_PROG_CC_C99
-
-# AC_PROG_CC_C99
-# --------------
-AC_DEFUN([AC_PROG_CC_C99],
-[ AC_REQUIRE([AC_PROG_CC])dnl
-  _AC_PROG_CC_C99
-])
-
-# AC_USE_SYSTEM_EXTENSIONS
-# ------------------------
-# Enable extensions on systems that normally disable them,
-# typically due to standards-conformance issues.
-m4_ifndef([AC_USE_SYSTEM_EXTENSIONS],[
-AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
-[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
-AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
-
-  AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
-  if test "$MINIX" = yes; then
-    AC_DEFINE([_POSIX_SOURCE], [1],
-      [Define to 1 if you need to in order for `stat' and other
-       things to work.])
-    AC_DEFINE([_POSIX_1_SOURCE], [2],
-      [Define to 2 if the system does not provide POSIX.1 features
-       except with this defined.])
-    AC_DEFINE([_MINIX], [1],
-      [Define to 1 if on MINIX.])
-  fi
-
-  AH_VERBATIM([__EXTENSIONS__],
-[/* Enable extensions on AIX 3, Interix.  */
-#ifndef _ALL_SOURCE
-# undef _ALL_SOURCE
-#endif
-/* Enable GNU extensions on systems that have them.  */
-#ifndef _GNU_SOURCE
-# undef _GNU_SOURCE
-#endif
-/* Enable threading extensions on Solaris.  */
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif
-/* Enable extensions on HP NonStop.  */
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
-/* Enable general extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-])
-  AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
-    [ac_cv_safe_to_define___extensions__],
-    [AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM([[
-#        define __EXTENSIONS__ 1
-         ]AC_INCLUDES_DEFAULT])],
-       [ac_cv_safe_to_define___extensions__=yes],
-       [ac_cv_safe_to_define___extensions__=no])])
-  test $ac_cv_safe_to_define___extensions__ = yes &&
-    AC_DEFINE([__EXTENSIONS__])
-  AC_DEFINE([_ALL_SOURCE])
-  AC_DEFINE([_GNU_SOURCE])
-  AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
-  AC_DEFINE([_TANDEM_SOURCE])
-])# AC_USE_SYSTEM_EXTENSIONS
-])
diff --git a/lib/replace/autogen-autotools.sh b/lib/replace/autogen-autotools.sh
deleted file mode 100755 (executable)
index d46a427..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-rm -rf autom4te.cache
-rm -f configure config.h.in
-
-autoheader || exit 1
-autoconf || exit 1
-
-rm -rf autom4te.cache
-
-echo "Now run ./configure and then make."
-exit 0
-
diff --git a/lib/replace/build_macros.m4 b/lib/replace/build_macros.m4
deleted file mode 100644 (file)
index c036668..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR,
-  [ AC_ARG_WITH([shared-build-dir],
-                [AC_HELP_STRING([--with-shared-build-dir=DIR],
-                                [temporary build directory where libraries are installed [$srcdir/sharedbuild]])])
-
-    sharedbuilddir="$srcdir/sharedbuild"
-    if test x"$with_shared_build_dir" != x; then
-        sharedbuilddir=$with_shared_build_dir
-        CFLAGS="$CFLAGS -I$with_shared_build_dir/include"
-        LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib"
-    fi
-    AC_SUBST(sharedbuilddir)
-  ])
-
diff --git a/lib/replace/config.guess b/lib/replace/config.guess
deleted file mode 100755 (executable)
index da83314..0000000
+++ /dev/null
@@ -1,1561 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-#   Free Software Foundation, Inc.
-
-timestamp='2009-04-27'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
-  -h, --help         print this help, then exit
-  -t, --time-stamp   print date of last modification, then exit
-  -v, --version      print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
-  case $1 in
-    --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit ;;
-    --version | -v )
-       echo "$version" ; exit ;;
-    --help | --h* | -h )
-       echo "$usage"; exit ;;
-    -- )     # Stop option processing
-       shift; break ;;
-    - )        # Use stdin as input.
-       break ;;
-    -* )
-       echo "$me: invalid option $1$help" >&2
-       exit 1 ;;
-    * )
-       break ;;
-  esac
-done
-
-if test $# != 0; then
-  echo "$me: too many arguments$help" >&2
-  exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,)    echo "int x;" > $dummy.c ;
-       for c in cc gcc c89 c99 ; do
-         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
-            CC_FOR_BUILD="$c"; break ;
-         fi ;
-       done ;
-       if test x"$CC_FOR_BUILD" = x ; then
-         CC_FOR_BUILD=no_compiler_found ;
-       fi
-       ;;
- ,,*)   CC_FOR_BUILD=$CC ;;
- ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
-       PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
-    *:NetBSD:*:*)
-       # NetBSD (nbsd) targets should (where applicable) match one or
-       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
-       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
-       # switched to ELF, *-*-netbsd* would select the old
-       # object file format.  This provides both forward
-       # compatibility and a consistent mechanism for selecting the
-       # object file format.
-       #
-       # Note: NetBSD doesn't particularly care about the vendor
-       # portion of the name.  We always set it to "unknown".
-       sysctl="sysctl -n hw.machine_arch"
-       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
-       case "${UNAME_MACHINE_ARCH}" in
-           armeb) machine=armeb-unknown ;;
-           arm*) machine=arm-unknown ;;
-           sh3el) machine=shl-unknown ;;
-           sh3eb) machine=sh-unknown ;;
-           sh5el) machine=sh5le-unknown ;;
-           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
-       esac
-       # The Operating System including object format, if it has switched
-       # to ELF recently, or will in the future.
-       case "${UNAME_MACHINE_ARCH}" in
-           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
-               eval $set_cc_for_build
-               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
-                       | grep __ELF__ >/dev/null
-               then
-                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
-                   # Return netbsd for either.  FIX?
-                   os=netbsd
-               else
-                   os=netbsdelf
-               fi
-               ;;
-           *)
-               os=netbsd
-               ;;
-       esac
-       # The OS release
-       # Debian GNU/NetBSD machines have a different userland, and
-       # thus, need a distinct triplet. However, they do not need
-       # kernel version information, so it can be replaced with a
-       # suitable tag, in the style of linux-gnu.
-       case "${UNAME_VERSION}" in
-           Debian*)
-               release='-gnu'
-               ;;
-           *)
-               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-               ;;
-       esac
-       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
-       # contains redundant information, the shorter form:
-       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-       echo "${machine}-${os}${release}"
-       exit ;;
-    *:OpenBSD:*:*)
-       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
-       exit ;;
-    *:ekkoBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
-       exit ;;
-    *:SolidBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
-       exit ;;
-    macppc:MirBSD:*:*)
-       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
-       exit ;;
-    *:MirBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
-       exit ;;
-    alpha:OSF1:*:*)
-       case $UNAME_RELEASE in
-       *4.0)
-               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
-               ;;
-       *5.*)
-               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
-               ;;
-       esac
-       # According to Compaq, /usr/sbin/psrinfo has been available on
-       # OSF/1 and Tru64 systems produced since 1995.  I hope that
-       # covers most systems running today.  This code pipes the CPU
-       # types through head -n 1, so we only detect the type of CPU 0.
-       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
-       case "$ALPHA_CPU_TYPE" in
-           "EV4 (21064)")
-               UNAME_MACHINE="alpha" ;;
-           "EV4.5 (21064)")
-               UNAME_MACHINE="alpha" ;;
-           "LCA4 (21066/21068)")
-               UNAME_MACHINE="alpha" ;;
-           "EV5 (21164)")
-               UNAME_MACHINE="alphaev5" ;;
-           "EV5.6 (21164A)")
-               UNAME_MACHINE="alphaev56" ;;
-           "EV5.6 (21164PC)")
-               UNAME_MACHINE="alphapca56" ;;
-           "EV5.7 (21164PC)")
-               UNAME_MACHINE="alphapca57" ;;
-           "EV6 (21264)")
-               UNAME_MACHINE="alphaev6" ;;
-           "EV6.7 (21264A)")
-               UNAME_MACHINE="alphaev67" ;;
-           "EV6.8CB (21264C)")
-               UNAME_MACHINE="alphaev68" ;;
-           "EV6.8AL (21264B)")
-               UNAME_MACHINE="alphaev68" ;;
-           "EV6.8CX (21264D)")
-               UNAME_MACHINE="alphaev68" ;;
-           "EV6.9A (21264/EV69A)")
-               UNAME_MACHINE="alphaev69" ;;
-           "EV7 (21364)")
-               UNAME_MACHINE="alphaev7" ;;
-           "EV7.9 (21364A)")
-               UNAME_MACHINE="alphaev79" ;;
-       esac
-       # A Pn.n version is a patched version.
-       # A Vn.n version is a released version.
-       # A Tn.n version is a released field test version.
-       # A Xn.n version is an unreleased experimental baselevel.
-       # 1.2 uses "1.2" for uname -r.
-       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-       exit ;;
-    Alpha\ *:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # Should we change UNAME_MACHINE based on the output of uname instead
-       # of the specific Alpha model?
-       echo alpha-pc-interix
-       exit ;;
-    21064:Windows_NT:50:3)
-       echo alpha-dec-winnt3.5
-       exit ;;
-    Amiga*:UNIX_System_V:4.0:*)
-       echo m68k-unknown-sysv4
-       exit ;;
-    *:[Aa]miga[Oo][Ss]:*:*)
-       echo ${UNAME_MACHINE}-unknown-amigaos
-       exit ;;
-    *:[Mm]orph[Oo][Ss]:*:*)
-       echo ${UNAME_MACHINE}-unknown-morphos
-       exit ;;
-    *:OS/390:*:*)
-       echo i370-ibm-openedition
-       exit ;;
-    *:z/VM:*:*)
-       echo s390-ibm-zvmoe
-       exit ;;
-    *:OS400:*:*)
-        echo powerpc-ibm-os400
-       exit ;;
-    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
-       echo arm-acorn-riscix${UNAME_RELEASE}
-       exit ;;
-    arm:riscos:*:*|arm:RISCOS:*:*)
-       echo arm-unknown-riscos
-       exit ;;
-    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
-       echo hppa1.1-hitachi-hiuxmpp
-       exit ;;
-    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
-       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
-       if test "`(/bin/universe) 2>/dev/null`" = att ; then
-               echo pyramid-pyramid-sysv3
-       else
-               echo pyramid-pyramid-bsd
-       fi
-       exit ;;
-    NILE*:*:*:dcosx)
-       echo pyramid-pyramid-svr4
-       exit ;;
-    DRS?6000:unix:4.0:6*)
-       echo sparc-icl-nx6
-       exit ;;
-    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
-       case `/usr/bin/uname -p` in
-           sparc) echo sparc-icl-nx7; exit ;;
-       esac ;;
-    s390x:SunOS:*:*)
-       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    sun4H:SunOS:5.*:*)
-       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-       eval $set_cc_for_build
-       SUN_ARCH="i386"
-       # If there is a compiler, see if it is configured for 64-bit objects.
-       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
-       # This test works for both compilers.
-       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-               grep IS_64BIT_ARCH >/dev/null
-           then
-               SUN_ARCH="x86_64"
-           fi
-       fi
-       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    sun4*:SunOS:6*:*)
-       # According to config.sub, this is the proper way to canonicalize
-       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
-       # it's likely to be more like Solaris than SunOS4.
-       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    sun4*:SunOS:*:*)
-       case "`/usr/bin/arch -k`" in
-           Series*|S4*)
-               UNAME_RELEASE=`uname -v`
-               ;;
-       esac
-       # Japanese Language versions have a version number like `4.1.3-JL'.
-       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
-       exit ;;
-    sun3*:SunOS:*:*)
-       echo m68k-sun-sunos${UNAME_RELEASE}
-       exit ;;
-    sun*:*:4.2BSD:*)
-       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
-       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
-       case "`/bin/arch`" in
-           sun3)
-               echo m68k-sun-sunos${UNAME_RELEASE}
-               ;;
-           sun4)
-               echo sparc-sun-sunos${UNAME_RELEASE}
-               ;;
-       esac
-       exit ;;
-    aushp:SunOS:*:*)
-       echo sparc-auspex-sunos${UNAME_RELEASE}
-       exit ;;
-    # The situation for MiNT is a little confusing.  The machine name
-    # can be virtually everything (everything which is not
-    # "atarist" or "atariste" at least should have a processor
-    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
-    # to the lowercase version "mint" (or "freemint").  Finally
-    # the system name "TOS" denotes a system which is actually not
-    # MiNT.  But MiNT is downward compatible to TOS, so this should
-    # be no problem.
-    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-       exit ;;
-    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
-       echo m68k-atari-mint${UNAME_RELEASE}
-        exit ;;
-    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-       exit ;;
-    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit ;;
-    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit ;;
-    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit ;;
-    m68k:machten:*:*)
-       echo m68k-apple-machten${UNAME_RELEASE}
-       exit ;;
-    powerpc:machten:*:*)
-       echo powerpc-apple-machten${UNAME_RELEASE}
-       exit ;;
-    RISC*:Mach:*:*)
-       echo mips-dec-mach_bsd4.3
-       exit ;;
-    RISC*:ULTRIX:*:*)
-       echo mips-dec-ultrix${UNAME_RELEASE}
-       exit ;;
-    VAX*:ULTRIX*:*:*)
-       echo vax-dec-ultrix${UNAME_RELEASE}
-       exit ;;
-    2020:CLIX:*:* | 2430:CLIX:*:*)
-       echo clipper-intergraph-clix${UNAME_RELEASE}
-       exit ;;
-    mips:*:*:UMIPS | mips:*:*:RISCos)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h>  /* for printf() prototype */
-       int main (int argc, char *argv[]) {
-#else
-       int main (argc, argv) int argc; char *argv[]; {
-#endif
-       #if defined (host_mips) && defined (MIPSEB)
-       #if defined (SYSTYPE_SYSV)
-         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
-       #endif
-       #if defined (SYSTYPE_SVR4)
-         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
-       #endif
-       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
-         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
-       #endif
-       #endif
-         exit (-1);
-       }
-EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c &&
-         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
-         SYSTEM_NAME=`$dummy $dummyarg` &&
-           { echo "$SYSTEM_NAME"; exit; }
-       echo mips-mips-riscos${UNAME_RELEASE}
-       exit ;;
-    Motorola:PowerMAX_OS:*:*)
-       echo powerpc-motorola-powermax
-       exit ;;
-    Motorola:*:4.3:PL8-*)
-       echo powerpc-harris-powermax
-       exit ;;
-    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
-       echo powerpc-harris-powermax
-       exit ;;
-    Night_Hawk:Power_UNIX:*:*)
-       echo powerpc-harris-powerunix
-       exit ;;
-    m88k:CX/UX:7*:*)
-       echo m88k-harris-cxux7
-       exit ;;
-    m88k:*:4*:R4*)
-       echo m88k-motorola-sysv4
-       exit ;;
-    m88k:*:3*:R3*)
-       echo m88k-motorola-sysv3
-       exit ;;
-    AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
-       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
-       then
-           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
-              [ ${TARGET_BINARY_INTERFACE}x = x ]
-           then
-               echo m88k-dg-dgux${UNAME_RELEASE}
-           else
-               echo m88k-dg-dguxbcs${UNAME_RELEASE}
-           fi
-       else
-           echo i586-dg-dgux${UNAME_RELEASE}
-       fi
-       exit ;;
-    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
-       echo m88k-dolphin-sysv3
-       exit ;;
-    M88*:*:R3*:*)
-       # Delta 88k system running SVR3
-       echo m88k-motorola-sysv3
-       exit ;;
-    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
-       echo m88k-tektronix-sysv3
-       exit ;;
-    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
-       echo m68k-tektronix-bsd
-       exit ;;
-    *:IRIX*:*:*)
-       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
-       exit ;;
-    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
-       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
-       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
-    i*86:AIX:*:*)
-       echo i386-ibm-aix
-       exit ;;
-    ia64:AIX:*:*)
-       if [ -x /usr/bin/oslevel ] ; then
-               IBM_REV=`/usr/bin/oslevel`
-       else
-               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-       fi
-       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
-       exit ;;
-    *:AIX:2:3)
-       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-               eval $set_cc_for_build
-               sed 's/^                //' << EOF >$dummy.c
-               #include <sys/systemcfg.h>
-
-               main()
-                       {
-                       if (!__power_pc())
-                               exit(1);
-                       puts("powerpc-ibm-aix3.2.5");
-                       exit(0);
-                       }
-EOF
-               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
-               then
-                       echo "$SYSTEM_NAME"
-               else
-                       echo rs6000-ibm-aix3.2.5
-               fi
-       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
-               echo rs6000-ibm-aix3.2.4
-       else
-               echo rs6000-ibm-aix3.2
-       fi
-       exit ;;
-    *:AIX:*:[456])
-       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
-       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
-               IBM_ARCH=rs6000
-       else
-               IBM_ARCH=powerpc
-       fi
-       if [ -x /usr/bin/oslevel ] ; then
-               IBM_REV=`/usr/bin/oslevel`
-       else
-               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-       fi
-       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
-       exit ;;
-    *:AIX:*:*)
-       echo rs6000-ibm-aix
-       exit ;;
-    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
-       echo romp-ibm-bsd4.4
-       exit ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
-       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
-       exit ;;                             # report: romp-ibm BSD 4.3
-    *:BOSX:*:*)
-       echo rs6000-bull-bosx
-       exit ;;
-    DPX/2?00:B.O.S.:*:*)
-       echo m68k-bull-sysv3
-       exit ;;
-    9000/[34]??:4.3bsd:1.*:*)
-       echo m68k-hp-bsd
-       exit ;;
-    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
-       echo m68k-hp-bsd4.4
-       exit ;;
-    9000/[34678]??:HP-UX:*:*)
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-       case "${UNAME_MACHINE}" in
-           9000/31? )            HP_ARCH=m68000 ;;
-           9000/[34]?? )         HP_ARCH=m68k ;;
-           9000/[678][0-9][0-9])
-               if [ -x /usr/bin/getconf ]; then
-                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
-                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
-               fi
-               if [ "${HP_ARCH}" = "" ]; then
-                   eval $set_cc_for_build
-                   sed 's/^              //' << EOF >$dummy.c
-
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
-
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
-
-                  switch (cpu)
-               {
-               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-               case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-                   switch (bits)
-                       {
-                       case 64: puts ("hppa2.0w"); break;
-                       case 32: puts ("hppa2.0n"); break;
-                       default: puts ("hppa2.0"); break;
-                       } break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-                   puts ("hppa2.0"); break;
-              #endif
-               default: puts ("hppa1.0"); break;
-               }
-                  exit (0);
-              }
-EOF
-                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
-                   test -z "$HP_ARCH" && HP_ARCH=hppa
-               fi ;;
-       esac
-       if [ ${HP_ARCH} = "hppa2.0w" ]
-       then
-           eval $set_cc_for_build
-
-           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
-           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
-           # generating 64-bit code.  GNU and HP use different nomenclature:
-           #
-           # $ CC_FOR_BUILD=cc ./config.guess
-           # => hppa2.0w-hp-hpux11.23
-           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
-           # => hppa64-hp-hpux11.23
-
-           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
-               grep __LP64__ >/dev/null
-           then
-               HP_ARCH="hppa2.0w"
-           else
-               HP_ARCH="hppa64"
-           fi
-       fi
-       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
-       exit ;;
-    ia64:HP-UX:*:*)
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-       echo ia64-hp-hpux${HPUX_REV}
-       exit ;;
-    3050*:HI-UX:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #include <unistd.h>
-       int
-       main ()
-       {
-         long cpu = sysconf (_SC_CPU_VERSION);
-         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
-            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
-            results, however.  */
-         if (CPU_IS_PA_RISC (cpu))
-           {
-             switch (cpu)
-               {
-                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
-                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
-                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
-                 default: puts ("hppa-hitachi-hiuxwe2"); break;
-               }
-           }
-         else if (CPU_IS_HP_MC68K (cpu))
-           puts ("m68k-hitachi-hiuxwe2");
-         else puts ("unknown-hitachi-hiuxwe2");
-         exit (0);
-       }
-EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
-               { echo "$SYSTEM_NAME"; exit; }
-       echo unknown-hitachi-hiuxwe2
-       exit ;;
-    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
-       echo hppa1.1-hp-bsd
-       exit ;;
-    9000/8??:4.3bsd:*:*)
-       echo hppa1.0-hp-bsd
-       exit ;;
-    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
-       echo hppa1.0-hp-mpeix
-       exit ;;
-    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
-       echo hppa1.1-hp-osf
-       exit ;;
-    hp8??:OSF1:*:*)
-       echo hppa1.0-hp-osf
-       exit ;;
-    i*86:OSF1:*:*)
-       if [ -x /usr/sbin/sysversion ] ; then
-           echo ${UNAME_MACHINE}-unknown-osf1mk
-       else
-           echo ${UNAME_MACHINE}-unknown-osf1
-       fi
-       exit ;;
-    parisc*:Lites*:*:*)
-       echo hppa1.1-hp-lites
-       exit ;;
-    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
-       echo c1-convex-bsd
-        exit ;;
-    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
-       if getsysinfo -f scalar_acc
-       then echo c32-convex-bsd
-       else echo c2-convex-bsd
-       fi
-        exit ;;
-    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
-       echo c34-convex-bsd
-        exit ;;
-    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
-       echo c38-convex-bsd
-        exit ;;
-    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
-       echo c4-convex-bsd
-        exit ;;
-    CRAY*Y-MP:*:*:*)
-       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    CRAY*[A-Z]90:*:*:*)
-       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
-       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-             -e 's/\.[^.]*$/.X/'
-       exit ;;
-    CRAY*TS:*:*:*)
-       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    CRAY*T3E:*:*:*)
-       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    CRAY*SV1:*:*:*)
-       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    *:UNICOS/mp:*:*)
-       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
-       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit ;;
-    5000:UNIX_System_V:4.*:*)
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-       exit ;;
-    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
-       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
-       exit ;;
-    sparc*:BSD/OS:*:*)
-       echo sparc-unknown-bsdi${UNAME_RELEASE}
-       exit ;;
-    *:BSD/OS:*:*)
-       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
-       exit ;;
-    *:FreeBSD:*:*)
-       case ${UNAME_MACHINE} in
-           pc98)
-               echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-           amd64)
-               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-           *)
-               echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-       esac
-       exit ;;
-    i*:CYGWIN*:*)
-       echo ${UNAME_MACHINE}-pc-cygwin
-       exit ;;
-    *:MINGW*:*)
-       echo ${UNAME_MACHINE}-pc-mingw32
-       exit ;;
-    i*:windows32*:*)
-       # uname -m includes "-pc" on this system.
-       echo ${UNAME_MACHINE}-mingw32
-       exit ;;
-    i*:PW*:*)
-       echo ${UNAME_MACHINE}-pc-pw32
-       exit ;;
-    *:Interix*:[3456]*)
-       case ${UNAME_MACHINE} in
-           x86)
-               echo i586-pc-interix${UNAME_RELEASE}
-               exit ;;
-           EM64T | authenticamd | genuineintel)
-               echo x86_64-unknown-interix${UNAME_RELEASE}
-               exit ;;
-           IA64)
-               echo ia64-unknown-interix${UNAME_RELEASE}
-               exit ;;
-       esac ;;
-    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-       echo i${UNAME_MACHINE}-pc-mks
-       exit ;;
-    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-       # UNAME_MACHINE based on the output of uname instead of i386?
-       echo i586-pc-interix
-       exit ;;
-    i*:UWIN*:*)
-       echo ${UNAME_MACHINE}-pc-uwin
-       exit ;;
-    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-       echo x86_64-unknown-cygwin
-       exit ;;
-    p*:CYGWIN*:*)
-       echo powerpcle-unknown-cygwin
-       exit ;;
-    prep*:SunOS:5.*:*)
-       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    *:GNU:*:*)
-       # the GNU system
-       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
-       exit ;;
-    *:GNU/*:*:*)
-       # other systems with GNU libc and userland
-       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
-       exit ;;
-    i*86:Minix:*:*)
-       echo ${UNAME_MACHINE}-pc-minix
-       exit ;;
-    arm*:Linux:*:*)
-       eval $set_cc_for_build
-       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
-           | grep -q __ARM_EABI__
-       then
-           echo ${UNAME_MACHINE}-unknown-linux-gnu
-       else
-           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
-       fi
-       exit ;;
-    avr32*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    cris:Linux:*:*)
-       echo cris-axis-linux-gnu
-       exit ;;
-    crisv32:Linux:*:*)
-       echo crisv32-axis-linux-gnu
-       exit ;;
-    frv:Linux:*:*)
-       echo frv-unknown-linux-gnu
-       exit ;;
-    ia64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    m32r*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    m68*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    mips:Linux:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #undef CPU
-       #undef mips
-       #undef mipsel
-       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-       CPU=mipsel
-       #else
-       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-       CPU=mips
-       #else
-       CPU=
-       #endif
-       #endif
-EOF
-       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-           /^CPU/{
-               s: ::g
-               p
-           }'`"
-       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
-       ;;
-    mips64:Linux:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #undef CPU
-       #undef mips64
-       #undef mips64el
-       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-       CPU=mips64el
-       #else
-       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-       CPU=mips64
-       #else
-       CPU=
-       #endif
-       #endif
-EOF
-       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-           /^CPU/{
-               s: ::g
-               p
-           }'`"
-       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
-       ;;
-    or32:Linux:*:*)
-       echo or32-unknown-linux-gnu
-       exit ;;
-    ppc:Linux:*:*)
-       echo powerpc-unknown-linux-gnu
-       exit ;;
-    ppc64:Linux:*:*)
-       echo powerpc64-unknown-linux-gnu
-       exit ;;
-    alpha:Linux:*:*)
-       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
-         EV5)   UNAME_MACHINE=alphaev5 ;;
-         EV56)  UNAME_MACHINE=alphaev56 ;;
-         PCA56) UNAME_MACHINE=alphapca56 ;;
-         PCA57) UNAME_MACHINE=alphapca56 ;;
-         EV6)   UNAME_MACHINE=alphaev6 ;;
-         EV67)  UNAME_MACHINE=alphaev67 ;;
-         EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
-       objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
-       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
-       exit ;;
-    padre:Linux:*:*)
-       echo sparc-unknown-linux-gnu
-       exit ;;
-    parisc:Linux:*:* | hppa:Linux:*:*)
-       # Look for CPU level
-       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-         PA7*) echo hppa1.1-unknown-linux-gnu ;;
-         PA8*) echo hppa2.0-unknown-linux-gnu ;;
-         *)    echo hppa-unknown-linux-gnu ;;
-       esac
-       exit ;;
-    parisc64:Linux:*:* | hppa64:Linux:*:*)
-       echo hppa64-unknown-linux-gnu
-       exit ;;
-    s390:Linux:*:* | s390x:Linux:*:*)
-       echo ${UNAME_MACHINE}-ibm-linux
-       exit ;;
-    sh64*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    sh*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    sparc:Linux:*:* | sparc64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    vax:Linux:*:*)
-       echo ${UNAME_MACHINE}-dec-linux-gnu
-       exit ;;
-    x86_64:Linux:*:*)
-       echo x86_64-unknown-linux-gnu
-       exit ;;
-    xtensa*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    i*86:Linux:*:*)
-       # The BFD linker knows what the default object file format is, so
-       # first see if it will tell us. cd to the root directory to prevent
-       # problems with other programs or directories called `ld' in the path.
-       # Set LC_ALL=C to ensure ld outputs messages in English.
-       ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
-                        | sed -ne '/supported targets:/!d
-                                   s/[         ][      ]*/ /g
-                                   s/.*supported targets: *//
-                                   s/ .*//
-                                   p'`
-        case "$ld_supported_targets" in
-         elf32-i386)
-               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
-               ;;
-         a.out-i386-linux)
-               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
-               exit ;;
-         "")
-               # Either a pre-BFD a.out linker (linux-gnuoldld) or
-               # one that does not give us useful --help.
-               echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
-               exit ;;
-       esac
-       # Determine whether the default compiler is a.out or elf
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #include <features.h>
-       #ifdef __ELF__
-       # ifdef __GLIBC__
-       #  if __GLIBC__ >= 2
-       LIBC=gnu
-       #  else
-       LIBC=gnulibc1
-       #  endif
-       # else
-       LIBC=gnulibc1
-       # endif
-       #else
-       #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-       LIBC=gnu
-       #else
-       LIBC=gnuaout
-       #endif
-       #endif
-       #ifdef __dietlibc__
-       LIBC=dietlibc
-       #endif
-EOF
-       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-           /^LIBC/{
-               s: ::g
-               p
-           }'`"
-       test x"${LIBC}" != x && {
-               echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
-               exit
-       }
-       test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
-       ;;
-    i*86:DYNIX/ptx:4*:*)
-       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
-       # earlier versions are messed up and put the nodename in both
-       # sysname and nodename.
-       echo i386-sequent-sysv4
-       exit ;;
-    i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
-       # I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
-       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
-       exit ;;
-    i*86:OS/2:*:*)
-       # If we were able to find `uname', then EMX Unix compatibility
-       # is probably installed.
-       echo ${UNAME_MACHINE}-pc-os2-emx
-       exit ;;
-    i*86:XTS-300:*:STOP)
-       echo ${UNAME_MACHINE}-unknown-stop
-       exit ;;
-    i*86:atheos:*:*)
-       echo ${UNAME_MACHINE}-unknown-atheos
-       exit ;;
-    i*86:syllable:*:*)
-       echo ${UNAME_MACHINE}-pc-syllable
-       exit ;;
-    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
-       echo i386-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    i*86:*DOS:*:*)
-       echo ${UNAME_MACHINE}-pc-msdosdjgpp
-       exit ;;
-    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
-       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
-       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
-       else
-               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
-       fi
-       exit ;;
-    i*86:*:5:[678]*)
-       # UnixWare 7.x, OpenUNIX and OpenServer 6.
-       case `/bin/uname -X | grep "^Machine"` in
-           *486*)           UNAME_MACHINE=i486 ;;
-           *Pentium)        UNAME_MACHINE=i586 ;;
-           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
-       esac
-       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
-       exit ;;
-    i*86:*:3.2:*)
-       if test -f /usr/options/cb.name; then
-               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
-               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
-       elif /bin/uname -X 2>/dev/null >/dev/null ; then
-               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
-               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
-               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
-                       && UNAME_MACHINE=i586
-               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
-                       && UNAME_MACHINE=i686
-               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
-                       && UNAME_MACHINE=i686
-               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
-       else
-               echo ${UNAME_MACHINE}-pc-sysv32
-       fi
-       exit ;;
-    pc:*:*:*)
-       # Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i586.
-       # Note: whatever this is, it MUST be the same as what config.sub
-       # prints for the "djgpp" host, or else GDB configury will decide that
-       # this is a cross-build.
-       echo i586-pc-msdosdjgpp
-        exit ;;
-    Intel:Mach:3*:*)
-       echo i386-pc-mach3
-       exit ;;
-    paragon:*:*:*)
-       echo i860-intel-osf1
-       exit ;;
-    i860:*:4.*:*) # i860-SVR4
-       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
-         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
-       else # Add other i860-SVR4 vendors below as they are discovered.
-         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
-       fi
-       exit ;;
-    mini*:CTIX:SYS*5:*)
-       # "miniframe"
-       echo m68010-convergent-sysv
-       exit ;;
-    mc68k:UNIX:SYSTEM5:3.51m)
-       echo m68k-convergent-sysv
-       exit ;;
-    M680?0:D-NIX:5.3:*)
-       echo m68k-diab-dnix
-       exit ;;
-    M68*:*:R3V[5678]*:*)
-       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
-    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
-       OS_REL=''
-       test -r /etc/.relid \
-       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
-    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && { echo i486-ncr-sysv4; exit; } ;;
-    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
-       OS_REL='.3'
-       test -r /etc/.relid \
-           && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
-       /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
-           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
-    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-       echo m68k-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    mc68030:UNIX_System_V:4.*:*)
-       echo m68k-atari-sysv4
-       exit ;;
-    TSUNAMI:LynxOS:2.*:*)
-       echo sparc-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    rs6000:LynxOS:2.*:*)
-       echo rs6000-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
-       echo powerpc-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    SM[BE]S:UNIX_SV:*:*)
-       echo mips-dde-sysv${UNAME_RELEASE}
-       exit ;;
-    RM*:ReliantUNIX-*:*:*)
-       echo mips-sni-sysv4
-       exit ;;
-    RM*:SINIX-*:*:*)
-       echo mips-sni-sysv4
-       exit ;;
-    *:SINIX-*:*:*)
-       if uname -p 2>/dev/null >/dev/null ; then
-               UNAME_MACHINE=`(uname -p) 2>/dev/null`
-               echo ${UNAME_MACHINE}-sni-sysv4
-       else
-               echo ns32k-sni-sysv
-       fi
-       exit ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <Richard.M.Bartel@ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit ;;
-    *:UNIX_System_V:4*:FTX*)
-       # From Gerald Hewes <hewes@openmarket.com>.
-       # How about differentiating between stratus architectures? -djm
-       echo hppa1.1-stratus-sysv4
-       exit ;;
-    *:*:*:FTX*)
-       # From seanf@swdc.stratus.com.
-       echo i860-stratus-sysv4
-       exit ;;
-    i*86:VOS:*:*)
-       # From Paul.Green@stratus.com.
-       echo ${UNAME_MACHINE}-stratus-vos
-       exit ;;
-    *:VOS:*:*)
-       # From Paul.Green@stratus.com.
-       echo hppa1.1-stratus-vos
-       exit ;;
-    mc68*:A/UX:*:*)
-       echo m68k-apple-aux${UNAME_RELEASE}
-       exit ;;
-    news*:NEWS-OS:6*:*)
-       echo mips-sony-newsos6
-       exit ;;
-    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
-       if [ -d /usr/nec ]; then
-               echo mips-nec-sysv${UNAME_RELEASE}
-       else
-               echo mips-unknown-sysv${UNAME_RELEASE}
-       fi
-        exit ;;
-    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
-       echo powerpc-be-beos
-       exit ;;
-    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
-       echo powerpc-apple-beos
-       exit ;;
-    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
-       echo i586-pc-beos
-       exit ;;
-    BePC:Haiku:*:*)    # Haiku running on Intel PC compatible.
-       echo i586-pc-haiku
-       exit ;;
-    SX-4:SUPER-UX:*:*)
-       echo sx4-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-5:SUPER-UX:*:*)
-       echo sx5-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-6:SUPER-UX:*:*)
-       echo sx6-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-7:SUPER-UX:*:*)
-       echo sx7-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-8:SUPER-UX:*:*)
-       echo sx8-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-8R:SUPER-UX:*:*)
-       echo sx8r-nec-superux${UNAME_RELEASE}
-       exit ;;
-    Power*:Rhapsody:*:*)
-       echo powerpc-apple-rhapsody${UNAME_RELEASE}
-       exit ;;
-    *:Rhapsody:*:*)
-       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
-       exit ;;
-    *:Darwin:*:*)
-       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-       case $UNAME_PROCESSOR in
-           unknown) UNAME_PROCESSOR=powerpc ;;
-       esac
-       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
-       exit ;;
-    *:procnto*:*:* | *:QNX:[0123456789]*:*)
-       UNAME_PROCESSOR=`uname -p`
-       if test "$UNAME_PROCESSOR" = "x86"; then
-               UNAME_PROCESSOR=i386
-               UNAME_MACHINE=pc
-       fi
-       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
-       exit ;;
-    *:QNX:*:4*)
-       echo i386-pc-qnx
-       exit ;;
-    NSE-?:NONSTOP_KERNEL:*:*)
-       echo nse-tandem-nsk${UNAME_RELEASE}
-       exit ;;
-    NSR-?:NONSTOP_KERNEL:*:*)
-       echo nsr-tandem-nsk${UNAME_RELEASE}
-       exit ;;
-    *:NonStop-UX:*:*)
-       echo mips-compaq-nonstopux
-       exit ;;
-    BS2000:POSIX*:*:*)
-       echo bs2000-siemens-sysv
-       exit ;;
-    DS/*:UNIX_System_V:*:*)
-       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
-       exit ;;
-    *:Plan9:*:*)
-       # "uname -m" is not consistent, so use $cputype instead. 386
-       # is converted to i386 for consistency with other x86
-       # operating systems.
-       if test "$cputype" = "386"; then
-           UNAME_MACHINE=i386
-       else
-           UNAME_MACHINE="$cputype"
-       fi
-       echo ${UNAME_MACHINE}-unknown-plan9
-       exit ;;
-    *:TOPS-10:*:*)
-       echo pdp10-unknown-tops10
-       exit ;;
-    *:TENEX:*:*)
-       echo pdp10-unknown-tenex
-       exit ;;
-    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
-       echo pdp10-dec-tops20
-       exit ;;
-    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
-       echo pdp10-xkl-tops20
-       exit ;;
-    *:TOPS-20:*:*)
-       echo pdp10-unknown-tops20
-       exit ;;
-    *:ITS:*:*)
-       echo pdp10-unknown-its
-       exit ;;
-    SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
-       exit ;;
-    *:DragonFly:*:*)
-       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
-       exit ;;
-    *:*VMS:*:*)
-       UNAME_MACHINE=`(uname -p) 2>/dev/null`
-       case "${UNAME_MACHINE}" in
-           A*) echo alpha-dec-vms ; exit ;;
-           I*) echo ia64-dec-vms ; exit ;;
-           V*) echo vax-dec-vms ; exit ;;
-       esac ;;
-    *:XENIX:*:SysV)
-       echo i386-pc-xenix
-       exit ;;
-    i*86:skyos:*:*)
-       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
-       exit ;;
-    i*86:rdos:*:*)
-       echo ${UNAME_MACHINE}-pc-rdos
-       exit ;;
-    i*86:AROS:*:*)
-       echo ${UNAME_MACHINE}-pc-aros
-       exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
-  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-     I don't know....  */
-  printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
-  printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
-          "4"
-#else
-         ""
-#endif
-         ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
-  printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
-  int version;
-  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  if (version < 4)
-    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-  else
-    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-  exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
-  printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
-  printf ("ns32k-encore-mach\n"); exit (0);
-#else
-  printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
-  printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
-  printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
-  printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
-    struct utsname un;
-
-    uname(&un);
-
-    if (strncmp(un.version, "V2", 2) == 0) {
-       printf ("i386-sequent-ptx2\n"); exit (0);
-    }
-    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-       printf ("i386-sequent-ptx1\n"); exit (0);
-    }
-    printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-#  include <sys/param.h>
-#  if defined (BSD)
-#   if BSD == 43
-      printf ("vax-dec-bsd4.3\n"); exit (0);
-#   else
-#    if BSD == 199006
-      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-#    else
-      printf ("vax-dec-bsd\n"); exit (0);
-#    endif
-#   endif
-#  else
-    printf ("vax-dec-bsd\n"); exit (0);
-#  endif
-# else
-    printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
-  printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
-  exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-       { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
-    case `getsysinfo -f cpu_type` in
-    c1*)
-       echo c1-convex-bsd
-       exit ;;
-    c2*)
-       if getsysinfo -f scalar_acc
-       then echo c32-convex-bsd
-       else echo c2-convex-bsd
-       fi
-       exit ;;
-    c34*)
-       echo c34-convex-bsd
-       exit ;;
-    c38*)
-       echo c38-convex-bsd
-       exit ;;
-    c4*)
-       echo c4-convex-bsd
-       exit ;;
-    esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
-and
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo               = `(hostinfo) 2>/dev/null`
-/bin/universe          = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch              = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM  = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/lib/replace/config.sub b/lib/replace/config.sub
deleted file mode 100755 (executable)
index a39437d..0000000
+++ /dev/null
@@ -1,1686 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-#   Free Software Foundation, Inc.
-
-timestamp='2009-04-17'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support.  The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
-       $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
-  -h, --help         print this help, then exit
-  -t, --time-stamp   print date of last modification, then exit
-  -v, --version      print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
-  case $1 in
-    --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit ;;
-    --version | -v )
-       echo "$version" ; exit ;;
-    --help | --h* | -h )
-       echo "$usage"; exit ;;
-    -- )     # Stop option processing
-       shift; break ;;
-    - )        # Use stdin as input.
-       break ;;
-    -* )
-       echo "$me: invalid option $1$help"
-       exit 1 ;;
-
-    *local*)
-       # First pass through any local machine types.
-       echo $1
-       exit ;;
-
-    * )
-       break ;;
-  esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
-    exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
-    exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
-  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
-  kopensolaris*-gnu* | \
-  storm-chaos* | os2-emx* | rtmk-nova*)
-    os=-$maybe_os
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
-    ;;
-  *)
-    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-    if [ $basic_machine != $1 ]
-    then os=`echo $1 | sed 's/.*-/-/'`
-    else os=; fi
-    ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work.  We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
-       -sun*os*)
-               # Prevent following clause from handling this invalid input.
-               ;;
-       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-       -apple | -axis | -knuth | -cray)
-               os=
-               basic_machine=$1
-               ;;
-       -sim | -cisco | -oki | -wec | -winbond)
-               os=
-               basic_machine=$1
-               ;;
-       -scout)
-               ;;
-       -wrs)
-               os=-vxworks
-               basic_machine=$1
-               ;;
-       -chorusos*)
-               os=-chorusos
-               basic_machine=$1
-               ;;
-       -chorusrdb)
-               os=-chorusrdb
-               basic_machine=$1
-               ;;
-       -hiux*)
-               os=-hiuxwe2
-               ;;
-       -sco6)
-               os=-sco5v6
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco5)
-               os=-sco3.2v5
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco4)
-               os=-sco3.2v4
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco3.2.[4-9]*)
-               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco3.2v[4-9]*)
-               # Don't forget version if it is 3.2v4 or newer.
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco5v6*)
-               # Don't forget version if it is 3.2v4 or newer.
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco*)
-               os=-sco3.2v2
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -udk*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -isc)
-               os=-isc2.2
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -clix*)
-               basic_machine=clipper-intergraph
-               ;;
-       -isc*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -lynx*)
-               os=-lynxos
-               ;;
-       -ptx*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
-               ;;
-       -windowsnt*)
-               os=`echo $os | sed -e 's/windowsnt/winnt/'`
-               ;;
-       -psos*)
-               os=-psos
-               ;;
-       -mint | -mint[0-9]*)
-               basic_machine=m68k-atari
-               os=-mint
-               ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
-       # Recognize the basic CPU types without company name.
-       # Some are omitted here because they have special meanings below.
-       1750a | 580 \
-       | a29k \
-       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
-       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
-       | am33_2.0 \
-       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
-       | bfin \
-       | c4x | clipper \
-       | d10v | d30v | dlx | dsp16xx \
-       | fido | fr30 | frv \
-       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
-       | i370 | i860 | i960 | ia64 \
-       | ip2k | iq2000 \
-       | lm32 \
-       | m32c | m32r | m32rle | m68000 | m68k | m88k \
-       | maxq | mb | microblaze | mcore | mep | metag \
-       | mips | mipsbe | mipseb | mipsel | mipsle \
-       | mips16 \
-       | mips64 | mips64el \
-       | mips64octeon | mips64octeonel \
-       | mips64orion | mips64orionel \
-       | mips64r5900 | mips64r5900el \
-       | mips64vr | mips64vrel \
-       | mips64vr4100 | mips64vr4100el \
-       | mips64vr4300 | mips64vr4300el \
-       | mips64vr5000 | mips64vr5000el \
-       | mips64vr5900 | mips64vr5900el \
-       | mipsisa32 | mipsisa32el \
-       | mipsisa32r2 | mipsisa32r2el \
-       | mipsisa64 | mipsisa64el \
-       | mipsisa64r2 | mipsisa64r2el \
-       | mipsisa64sb1 | mipsisa64sb1el \
-       | mipsisa64sr71k | mipsisa64sr71kel \
-       | mipstx39 | mipstx39el \
-       | mn10200 | mn10300 \
-       | moxie \
-       | mt \
-       | msp430 \
-       | nios | nios2 \
-       | ns16k | ns32k \
-       | or32 \
-       | pdp10 | pdp11 | pj | pjl \
-       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
-       | pyramid \
-       | score \
-       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
-       | sh64 | sh64le \
-       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
-       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-       | spu | strongarm \
-       | tahoe | thumb | tic4x | tic80 | tron \
-       | v850 | v850e \
-       | we32k \
-       | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
-       | z8k | z80)
-               basic_machine=$basic_machine-unknown
-               ;;
-       m6811 | m68hc11 | m6812 | m68hc12)
-               # Motorola 68HC11/12.
-               basic_machine=$basic_machine-unknown
-               os=-none
-               ;;
-       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
-               ;;
-       ms1)
-               basic_machine=mt-unknown
-               ;;
-
-       # We use `pc' rather than `unknown'
-       # because (1) that's what they normally are, and
-       # (2) the word "unknown" tends to confuse beginning users.
-       i*86 | x86_64)
-         basic_machine=$basic_machine-pc
-         ;;
-       # Object if more than one company name word.
-       *-*-*)
-               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-               exit 1
-               ;;
-       # Recognize the basic CPU types with company name.
-       580-* \
-       | a29k-* \
-       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
-       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
-       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
-       | avr-* | avr32-* \
-       | bfin-* | bs2000-* \
-       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
-       | clipper-* | craynv-* | cydra-* \
-       | d10v-* | d30v-* | dlx-* \
-       | elxsi-* \
-       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
-       | h8300-* | h8500-* \
-       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
-       | i*86-* | i860-* | i960-* | ia64-* \
-       | ip2k-* | iq2000-* \
-       | lm32-* \
-       | m32c-* | m32r-* | m32rle-* \
-       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-       | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
-       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
-       | mips16-* \
-       | mips64-* | mips64el-* \
-       | mips64octeon-* | mips64octeonel-* \
-       | mips64orion-* | mips64orionel-* \
-       | mips64r5900-* | mips64r5900el-* \
-       | mips64vr-* | mips64vrel-* \
-       | mips64vr4100-* | mips64vr4100el-* \
-       | mips64vr4300-* | mips64vr4300el-* \
-       | mips64vr5000-* | mips64vr5000el-* \
-       | mips64vr5900-* | mips64vr5900el-* \
-       | mipsisa32-* | mipsisa32el-* \
-       | mipsisa32r2-* | mipsisa32r2el-* \
-       | mipsisa64-* | mipsisa64el-* \
-       | mipsisa64r2-* | mipsisa64r2el-* \
-       | mipsisa64sb1-* | mipsisa64sb1el-* \
-       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
-       | mipstx39-* | mipstx39el-* \
-       | mmix-* \
-       | mt-* \
-       | msp430-* \
-       | nios-* | nios2-* \
-       | none-* | np1-* | ns16k-* | ns32k-* \
-       | orion-* \
-       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
-       | pyramid-* \
-       | romp-* | rs6000-* \
-       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
-       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-       | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
-       | sparclite-* \
-       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
-       | tahoe-* | thumb-* \
-       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
-       | tron-* \
-       | v850-* | v850e-* | vax-* \
-       | we32k-* \
-       | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
-       | xstormy16-* | xtensa*-* \
-       | ymp-* \
-       | z8k-* | z80-*)
-               ;;
-       # Recognize the basic CPU types without company name, with glob match.
-       xtensa*)
-               basic_machine=$basic_machine-unknown
-               ;;
-       # Recognize the various machine names and aliases which stand
-       # for a CPU type and a company and sometimes even an OS.
-       386bsd)
-               basic_machine=i386-unknown
-               os=-bsd
-               ;;
-       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
-               basic_machine=m68000-att
-               ;;
-       3b*)
-               basic_machine=we32k-att
-               ;;
-       a29khif)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
-       abacus)
-               basic_machine=abacus-unknown
-               ;;
-       adobe68k)
-               basic_machine=m68010-adobe
-               os=-scout
-               ;;
-       alliant | fx80)
-               basic_machine=fx80-alliant
-               ;;
-       altos | altos3068)
-               basic_machine=m68k-altos
-               ;;
-       am29k)
-               basic_machine=a29k-none
-               os=-bsd
-               ;;
-       amd64)
-               basic_machine=x86_64-pc
-               ;;
-       amd64-*)
-               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       amdahl)
-               basic_machine=580-amdahl
-               os=-sysv
-               ;;
-       amiga | amiga-*)
-               basic_machine=m68k-unknown
-               ;;
-       amigaos | amigados)
-               basic_machine=m68k-unknown
-               os=-amigaos
-               ;;
-       amigaunix | amix)
-               basic_machine=m68k-unknown
-               os=-sysv4
-               ;;
-       apollo68)
-               basic_machine=m68k-apollo
-               os=-sysv
-               ;;
-       apollo68bsd)
-               basic_machine=m68k-apollo
-               os=-bsd
-               ;;
-       aros)
-               basic_machine=i386-pc
-               os=-aros
-               ;;
-       aux)
-               basic_machine=m68k-apple
-               os=-aux
-               ;;
-       balance)
-               basic_machine=ns32k-sequent
-               os=-dynix
-               ;;
-       blackfin)
-               basic_machine=bfin-unknown
-               os=-linux
-               ;;
-       blackfin-*)
-               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
-       c90)
-               basic_machine=c90-cray
-               os=-unicos
-               ;;
-        cegcc)
-               basic_machine=arm-unknown
-               os=-cegcc
-               ;;
-       convex-c1)
-               basic_machine=c1-convex
-               os=-bsd
-               ;;
-       convex-c2)
-               basic_machine=c2-convex
-               os=-bsd
-               ;;
-       convex-c32)
-               basic_machine=c32-convex
-               os=-bsd
-               ;;
-       convex-c34)
-               basic_machine=c34-convex
-               os=-bsd
-               ;;
-       convex-c38)
-               basic_machine=c38-convex
-               os=-bsd
-               ;;
-       cray | j90)
-               basic_machine=j90-cray
-               os=-unicos
-               ;;
-       craynv)
-               basic_machine=craynv-cray
-               os=-unicosmp
-               ;;
-       cr16)
-               basic_machine=cr16-unknown
-               os=-elf
-               ;;
-       crds | unos)
-               basic_machine=m68k-crds
-               ;;
-       crisv32 | crisv32-* | etraxfs*)
-               basic_machine=crisv32-axis
-               ;;
-       cris | cris-* | etrax*)
-               basic_machine=cris-axis
-               ;;
-       crx)
-               basic_machine=crx-unknown
-               os=-elf
-               ;;
-       da30 | da30-*)
-               basic_machine=m68k-da30
-               ;;
-       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
-               basic_machine=mips-dec
-               ;;
-       decsystem10* | dec10*)
-               basic_machine=pdp10-dec
-               os=-tops10
-               ;;
-       decsystem20* | dec20*)
-               basic_machine=pdp10-dec
-               os=-tops20
-               ;;
-       delta | 3300 | motorola-3300 | motorola-delta \
-             | 3300-motorola | delta-motorola)
-               basic_machine=m68k-motorola
-               ;;
-       delta88)
-               basic_machine=m88k-motorola
-               os=-sysv3
-               ;;
-       dicos)
-               basic_machine=i686-pc
-               os=-dicos
-               ;;
-       djgpp)
-               basic_machine=i586-pc
-               os=-msdosdjgpp
-               ;;
-       dpx20 | dpx20-*)
-               basic_machine=rs6000-bull
-               os=-bosx
-               ;;
-       dpx2* | dpx2*-bull)
-               basic_machine=m68k-bull
-               os=-sysv3
-               ;;
-       ebmon29k)
-               basic_machine=a29k-amd
-               os=-ebmon
-               ;;
-       elxsi)
-               basic_machine=elxsi-elxsi
-               os=-bsd
-               ;;
-       encore | umax | mmax)
-               basic_machine=ns32k-encore
-               ;;
-       es1800 | OSE68k | ose68k | ose | OSE)
-               basic_machine=m68k-ericsson
-               os=-ose
-               ;;
-       fx2800)
-               basic_machine=i860-alliant
-               ;;
-       genix)
-               basic_machine=ns32k-ns
-               ;;
-       gmicro)
-               basic_machine=tron-gmicro
-               os=-sysv
-               ;;
-       go32)
-               basic_machine=i386-pc
-               os=-go32
-               ;;
-       h3050r* | hiux*)
-               basic_machine=hppa1.1-hitachi
-               os=-hiuxwe2
-               ;;
-       h8300hms)
-               basic_machine=h8300-hitachi
-               os=-hms
-               ;;
-       h8300xray)
-               basic_machine=h8300-hitachi
-               os=-xray
-               ;;
-       h8500hms)
-               basic_machine=h8500-hitachi
-               os=-hms
-               ;;
-       harris)
-               basic_machine=m88k-harris
-               os=-sysv3
-               ;;
-       hp300-*)
-               basic_machine=m68k-hp
-               ;;
-       hp300bsd)
-               basic_machine=m68k-hp
-               os=-bsd
-               ;;
-       hp300hpux)
-               basic_machine=m68k-hp
-               os=-hpux
-               ;;
-       hp3k9[0-9][0-9] | hp9[0-9][0-9])
-               basic_machine=hppa1.0-hp
-               ;;
-       hp9k2[0-9][0-9] | hp9k31[0-9])
-               basic_machine=m68000-hp
-               ;;
-       hp9k3[2-9][0-9])
-               basic_machine=m68k-hp
-               ;;
-       hp9k6[0-9][0-9] | hp6[0-9][0-9])
-               basic_machine=hppa1.0-hp
-               ;;
-       hp9k7[0-79][0-9] | hp7[0-79][0-9])
-               basic_machine=hppa1.1-hp
-               ;;
-       hp9k78[0-9] | hp78[0-9])
-               # FIXME: really hppa2.0-hp
-               basic_machine=hppa1.1-hp
-               ;;
-       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
-               # FIXME: really hppa2.0-hp
-               basic_machine=hppa1.1-hp
-               ;;
-       hp9k8[0-9][13679] | hp8[0-9][13679])
-               basic_machine=hppa1.1-hp
-               ;;
-       hp9k8[0-9][0-9] | hp8[0-9][0-9])
-               basic_machine=hppa1.0-hp
-               ;;
-       hppa-next)
-               os=-nextstep3
-               ;;
-       hppaosf)
-               basic_machine=hppa1.1-hp
-               os=-osf
-               ;;
-       hppro)
-               basic_machine=hppa1.1-hp
-               os=-proelf
-               ;;
-       i370-ibm* | ibm*)
-               basic_machine=i370-ibm
-               ;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
-       i*86v32)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv32
-               ;;
-       i*86v4*)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv4
-               ;;
-       i*86v)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv
-               ;;
-       i*86sol2)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-solaris2
-               ;;
-       i386mach)
-               basic_machine=i386-mach
-               os=-mach
-               ;;
-       i386-vsta | vsta)
-               basic_machine=i386-unknown
-               os=-vsta
-               ;;
-       iris | iris4d)
-               basic_machine=mips-sgi
-               case $os in
-                   -irix*)
-                       ;;
-                   *)
-                       os=-irix4
-                       ;;
-               esac
-               ;;
-       isi68 | isi)
-               basic_machine=m68k-isi
-               os=-sysv
-               ;;
-       m68knommu)
-               basic_machine=m68k-unknown
-               os=-linux
-               ;;
-       m68knommu-*)
-               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
-       m88k-omron*)
-               basic_machine=m88k-omron
-               ;;
-       magnum | m3230)
-               basic_machine=mips-mips
-               os=-sysv
-               ;;
-       merlin)
-               basic_machine=ns32k-utek
-               os=-sysv
-               ;;
-       mingw32)
-               basic_machine=i386-pc
-               os=-mingw32
-               ;;
-       mingw32ce)
-               basic_machine=arm-unknown
-               os=-mingw32ce
-               ;;
-       miniframe)
-               basic_machine=m68000-convergent
-               ;;
-       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
-               basic_machine=m68k-atari
-               os=-mint
-               ;;
-       mips3*-*)
-               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
-               ;;
-       mips3*)
-               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
-               ;;
-       monitor)
-               basic_machine=m68k-rom68k
-               os=-coff
-               ;;
-       morphos)
-               basic_machine=powerpc-unknown
-               os=-morphos
-               ;;
-       msdos)
-               basic_machine=i386-pc
-               os=-msdos
-               ;;
-       ms1-*)
-               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
-               ;;
-       mvs)
-               basic_machine=i370-ibm
-               os=-mvs
-               ;;
-       ncr3000)
-               basic_machine=i486-ncr
-               os=-sysv4
-               ;;
-       netbsd386)
-               basic_machine=i386-unknown
-               os=-netbsd
-               ;;
-       netwinder)
-               basic_machine=armv4l-rebel
-               os=-linux
-               ;;
-       news | news700 | news800 | news900)
-               basic_machine=m68k-sony
-               os=-newsos
-               ;;
-       news1000)
-               basic_machine=m68030-sony
-               os=-newsos
-               ;;
-       news-3600 | risc-news)
-               basic_machine=mips-sony
-               os=-newsos
-               ;;
-       necv70)
-               basic_machine=v70-nec
-               os=-sysv
-               ;;
-       next | m*-next )
-               basic_machine=m68k-next
-               case $os in
-                   -nextstep* )
-                       ;;
-                   -ns2*)
-                     os=-nextstep2
-                       ;;
-                   *)
-                     os=-nextstep3
-                       ;;
-               esac
-               ;;
-       nh3000)
-               basic_machine=m68k-harris
-               os=-cxux
-               ;;
-       nh[45]000)
-               basic_machine=m88k-harris
-               os=-cxux
-               ;;
-       nindy960)
-               basic_machine=i960-intel
-               os=-nindy
-               ;;
-       mon960)
-               basic_machine=i960-intel
-               os=-mon960
-               ;;
-       nonstopux)
-               basic_machine=mips-compaq
-               os=-nonstopux
-               ;;
-       np1)
-               basic_machine=np1-gould
-               ;;
-       nsr-tandem)
-               basic_machine=nsr-tandem
-               ;;
-       op50n-* | op60c-*)
-               basic_machine=hppa1.1-oki
-               os=-proelf
-               ;;
-       openrisc | openrisc-*)
-               basic_machine=or32-unknown
-               ;;
-       os400)
-               basic_machine=powerpc-ibm
-               os=-os400
-               ;;
-       OSE68000 | ose68000)
-               basic_machine=m68000-ericsson
-               os=-ose
-               ;;
-       os68k)
-               basic_machine=m68k-none
-               os=-os68k
-               ;;
-       pa-hitachi)
-               basic_machine=hppa1.1-hitachi
-               os=-hiuxwe2
-               ;;
-       paragon)
-               basic_machine=i860-intel
-               os=-osf
-               ;;
-       parisc)
-               basic_machine=hppa-unknown
-               os=-linux
-               ;;
-       parisc-*)
-               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
-       pbd)
-               basic_machine=sparc-tti
-               ;;
-       pbb)
-               basic_machine=m68k-tti
-               ;;
-       pc532 | pc532-*)
-               basic_machine=ns32k-pc532
-               ;;
-       pc98)
-               basic_machine=i386-pc
-               ;;
-       pc98-*)
-               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pentium | p5 | k5 | k6 | nexgen | viac3)
-               basic_machine=i586-pc
-               ;;
-       pentiumpro | p6 | 6x86 | athlon | athlon_*)
-               basic_machine=i686-pc
-               ;;
-       pentiumii | pentium2 | pentiumiii | pentium3)
-               basic_machine=i686-pc
-               ;;
-       pentium4)
-               basic_machine=i786-pc
-               ;;
-       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
-               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pentiumpro-* | p6-* | 6x86-* | athlon-*)
-               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
-               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pentium4-*)
-               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pn)
-               basic_machine=pn-gould
-               ;;
-       power)  basic_machine=power-ibm
-               ;;
-       ppc)    basic_machine=powerpc-unknown
-               ;;
-       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ppcle | powerpclittle | ppc-le | powerpc-little)
-               basic_machine=powerpcle-unknown
-               ;;
-       ppcle-* | powerpclittle-*)
-               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ppc64)  basic_machine=powerpc64-unknown
-               ;;
-       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
-               basic_machine=powerpc64le-unknown
-               ;;
-       ppc64le-* | powerpc64little-*)
-               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ps2)
-               basic_machine=i386-ibm
-               ;;
-       pw32)
-               basic_machine=i586-unknown
-               os=-pw32
-               ;;
-       rdos)
-               basic_machine=i386-pc
-               os=-rdos
-               ;;
-       rom68k)
-               basic_machine=m68k-rom68k
-               os=-coff
-               ;;
-       rm[46]00)
-               basic_machine=mips-siemens
-               ;;
-       rtpc | rtpc-*)
-               basic_machine=romp-ibm
-               ;;
-       s390 | s390-*)
-               basic_machine=s390-ibm
-               ;;
-       s390x | s390x-*)
-               basic_machine=s390x-ibm
-               ;;
-       sa29200)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
-       sb1)
-               basic_machine=mipsisa64sb1-unknown
-               ;;
-       sb1el)
-               basic_machine=mipsisa64sb1el-unknown
-               ;;
-       sde)
-               basic_machine=mipsisa32-sde
-               os=-elf
-               ;;
-       sei)
-               basic_machine=mips-sei
-               os=-seiux
-               ;;
-       sequent)
-               basic_machine=i386-sequent
-               ;;
-       sh)
-               basic_machine=sh-hitachi
-               os=-hms
-               ;;
-       sh5el)
-               basic_machine=sh5le-unknown
-               ;;
-       sh64)
-               basic_machine=sh64-unknown
-               ;;
-       sparclite-wrs | simso-wrs)
-               basic_machine=sparclite-wrs
-               os=-vxworks
-               ;;
-       sps7)
-               basic_machine=m68k-bull
-               os=-sysv2
-               ;;
-       spur)
-               basic_machine=spur-unknown
-               ;;
-       st2000)
-               basic_machine=m68k-tandem
-               ;;
-       stratus)
-               basic_machine=i860-stratus
-               os=-sysv4
-               ;;
-       sun2)
-               basic_machine=m68000-sun
-               ;;
-       sun2os3)
-               basic_machine=m68000-sun
-               os=-sunos3
-               ;;
-       sun2os4)
-               basic_machine=m68000-sun
-               os=-sunos4
-               ;;
-       sun3os3)
-               basic_machine=m68k-sun
-               os=-sunos3
-               ;;
-       sun3os4)
-               basic_machine=m68k-sun
-               os=-sunos4
-               ;;
-       sun4os3)
-               basic_machine=sparc-sun
-               os=-sunos3
-               ;;
-       sun4os4)
-               basic_machine=sparc-sun
-               os=-sunos4
-               ;;
-       sun4sol2)
-               basic_machine=sparc-sun
-               os=-solaris2
-               ;;
-       sun3 | sun3-*)
-               basic_machine=m68k-sun
-               ;;
-       sun4)
-               basic_machine=sparc-sun
-               ;;
-       sun386 | sun386i | roadrunner)
-               basic_machine=i386-sun
-               ;;
-       sv1)
-               basic_machine=sv1-cray
-               os=-unicos
-               ;;
-       symmetry)
-               basic_machine=i386-sequent
-               os=-dynix
-               ;;
-       t3e)
-               basic_machine=alphaev5-cray
-               os=-unicos
-               ;;
-       t90)
-               basic_machine=t90-cray
-               os=-unicos
-               ;;
-       tic54x | c54x*)
-               basic_machine=tic54x-unknown
-               os=-coff
-               ;;
-       tic55x | c55x*)
-               basic_machine=tic55x-unknown
-               os=-coff
-               ;;
-       tic6x | c6x*)
-               basic_machine=tic6x-unknown
-               os=-coff
-               ;;
-       tile*)
-               basic_machine=tile-unknown
-               os=-linux-gnu
-               ;;
-       tx39)
-               basic_machine=mipstx39-unknown
-               ;;
-       tx39el)
-               basic_machine=mipstx39el-unknown
-               ;;
-       toad1)
-               basic_machine=pdp10-xkl
-               os=-tops20
-               ;;
-       tower | tower-32)
-               basic_machine=m68k-ncr
-               ;;
-       tpf)
-               basic_machine=s390x-ibm
-               os=-tpf
-               ;;
-       udi29k)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
-       ultra3)
-               basic_machine=a29k-nyu
-               os=-sym1
-               ;;
-       v810 | necv810)
-               basic_machine=v810-nec
-               os=-none
-               ;;
-       vaxv)
-               basic_machine=vax-dec
-               os=-sysv
-               ;;
-       vms)
-               basic_machine=vax-dec
-               os=-vms
-               ;;
-       vpp*|vx|vx-*)
-               basic_machine=f301-fujitsu
-               ;;
-       vxworks960)
-               basic_machine=i960-wrs
-               os=-vxworks
-               ;;
-       vxworks68)
-               basic_machine=m68k-wrs
-               os=-vxworks
-               ;;
-       vxworks29k)
-               basic_machine=a29k-wrs
-               os=-vxworks
-               ;;
-       w65*)
-               basic_machine=w65-wdc
-               os=-none
-               ;;
-       w89k-*)
-               basic_machine=hppa1.1-winbond
-               os=-proelf
-               ;;
-       xbox)
-               basic_machine=i686-pc
-               os=-mingw32
-               ;;
-       xps | xps100)
-               basic_machine=xps100-honeywell
-               ;;
-       ymp)
-               basic_machine=ymp-cray
-               os=-unicos
-               ;;
-       z8k-*-coff)
-               basic_machine=z8k-unknown
-               os=-sim
-               ;;
-       z80-*-coff)
-               basic_machine=z80-unknown
-               os=-sim
-               ;;
-       none)
-               basic_machine=none-none
-               os=-none
-               ;;
-
-# Here we handle the default manufacturer of certain CPU types.  It is in
-# some cases the only manufacturer, in others, it is the most popular.
-       w89k)
-               basic_machine=hppa1.1-winbond
-               ;;
-       op50n)
-               basic_machine=hppa1.1-oki
-               ;;
-       op60c)
-               basic_machine=hppa1.1-oki
-               ;;
-       romp)
-               basic_machine=romp-ibm
-               ;;
-       mmix)
-               basic_machine=mmix-knuth
-               ;;
-       rs6000)
-               basic_machine=rs6000-ibm
-               ;;
-       vax)
-               basic_machine=vax-dec
-               ;;
-       pdp10)
-               # there are many clones, so DEC is not a safe bet
-               basic_machine=pdp10-unknown
-               ;;
-       pdp11)
-               basic_machine=pdp11-dec
-               ;;
-       we32k)
-               basic_machine=we32k-att
-               ;;
-       sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
-               basic_machine=sh-unknown
-               ;;
-       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
-               basic_machine=sparc-sun
-               ;;
-       cydra)
-               basic_machine=cydra-cydrome
-               ;;
-       orion)
-               basic_machine=orion-highlevel
-               ;;
-       orion105)
-               basic_machine=clipper-highlevel
-               ;;
-       mac | mpw | mac-mpw)
-               basic_machine=m68k-apple
-               ;;
-       pmac | pmac-mpw)
-               basic_machine=powerpc-apple
-               ;;
-       *-unknown)
-               # Make sure to match an already-canonicalized machine name.
-               ;;
-       *)
-               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-               exit 1
-               ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
-       *-digital*)
-               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
-               ;;
-       *-commodore*)
-               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
-               ;;
-       *)
-               ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
-       # -solaris* is a basic system type, with this one exception.
-       -solaris1 | -solaris1.*)
-               os=`echo $os | sed -e 's|solaris1|sunos4|'`
-               ;;
-       -solaris)
-               os=-solaris2
-               ;;
-       -svr4*)
-               os=-sysv4
-               ;;
-       -unixware*)
-               os=-sysv4.2uw
-               ;;
-       -gnu/linux*)
-               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
-               ;;
-       # First accept the basic system types.
-       # The portable systems comes first.
-       # Each alternative MUST END IN A *, to match a version number.
-       # -sysv* is not here because it comes later, after sysvr4.
-       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
-             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
-             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
-             | -kopensolaris* \
-             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-             | -aos* | -aros* \
-             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
-             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-             | -openbsd* | -solidbsd* \
-             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
-             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
-             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
-             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-             | -chorusos* | -chorusrdb* | -cegcc* \
-             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-             | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
-             | -uxpv* | -beos* | -mpeix* | -udk* \
-             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
-             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
-             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
-             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-             | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
-       # Remember, each alternative MUST END IN *, to match a version number.
-               ;;
-       -qnx*)
-               case $basic_machine in
-                   x86-* | i*86-*)
-                       ;;
-                   *)
-                       os=-nto$os
-                       ;;
-               esac
-               ;;
-       -nto-qnx*)
-               ;;
-       -nto*)
-               os=`echo $os | sed -e 's|nto|nto-qnx|'`
-               ;;
-       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
-             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
-               ;;
-       -mac*)
-               os=`echo $os | sed -e 's|mac|macos|'`
-               ;;
-       -linux-dietlibc)
-               os=-linux-dietlibc
-               ;;
-       -linux*)
-               os=`echo $os | sed -e 's|linux|linux-gnu|'`
-               ;;
-       -sunos5*)
-               os=`echo $os | sed -e 's|sunos5|solaris2|'`
-               ;;
-       -sunos6*)
-               os=`echo $os | sed -e 's|sunos6|solaris3|'`
-               ;;
-       -opened*)
-               os=-openedition
-               ;;
-        -os400*)
-               os=-os400
-               ;;
-       -wince*)
-               os=-wince
-               ;;
-       -osfrose*)
-               os=-osfrose
-               ;;
-       -osf*)
-               os=-osf
-               ;;
-       -utek*)
-               os=-bsd
-               ;;
-       -dynix*)
-               os=-bsd
-               ;;
-       -acis*)
-               os=-aos
-               ;;
-       -atheos*)
-               os=-atheos
-               ;;
-       -syllable*)
-               os=-syllable
-               ;;
-       -386bsd)
-               os=-bsd
-               ;;
-       -ctix* | -uts*)
-               os=-sysv
-               ;;
-       -nova*)
-               os=-rtmk-nova
-               ;;
-       -ns2 )
-               os=-nextstep2
-               ;;
-       -nsk*)
-               os=-nsk
-               ;;
-       # Preserve the version number of sinix5.
-       -sinix5.*)
-               os=`echo $os | sed -e 's|sinix|sysv|'`
-               ;;
-       -sinix*)
-               os=-sysv4
-               ;;
-        -tpf*)
-               os=-tpf
-               ;;
-       -triton*)
-               os=-sysv3
-               ;;
-       -oss*)
-               os=-sysv3
-               ;;
-       -svr4)
-               os=-sysv4
-               ;;
-       -svr3)
-               os=-sysv3
-               ;;
-       -sysvr4)
-               os=-sysv4
-               ;;
-       # This must come after -sysvr4.
-       -sysv*)
-               ;;
-       -ose*)
-               os=-ose
-               ;;
-       -es1800*)
-               os=-ose
-               ;;
-       -xenix)
-               os=-xenix
-               ;;
-       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-               os=-mint
-               ;;
-       -aros*)
-               os=-aros
-               ;;
-       -kaos*)
-               os=-kaos
-               ;;
-       -zvmoe)
-               os=-zvmoe
-               ;;
-       -dicos*)
-               os=-dicos
-               ;;
-       -none)
-               ;;
-       *)
-               # Get rid of the `-' at the beginning of $os.
-               os=`echo $os | sed 's/[^-]*-//'`
-               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
-               exit 1
-               ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system.  Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
-        score-*)
-               os=-elf
-               ;;
-        spu-*)
-               os=-elf
-               ;;
-       *-acorn)
-               os=-riscix1.2
-               ;;
-       arm*-rebel)
-               os=-linux
-               ;;
-       arm*-semi)
-               os=-aout
-               ;;
-        c4x-* | tic4x-*)
-               os=-coff
-               ;;
-       # This must come before the *-dec entry.
-       pdp10-*)
-               os=-tops20
-               ;;
-       pdp11-*)
-               os=-none
-               ;;
-       *-dec | vax-*)
-               os=-ultrix4.2
-               ;;
-       m68*-apollo)
-               os=-domain
-               ;;
-       i386-sun)
-               os=-sunos4.0.2
-               ;;
-       m68000-sun)
-               os=-sunos3
-               # This also exists in the configure program, but was not the
-               # default.
-               # os=-sunos4
-               ;;
-       m68*-cisco)
-               os=-aout
-               ;;
-        mep-*)
-               os=-elf
-               ;;
-       mips*-cisco)
-               os=-elf
-               ;;
-       mips*-*)
-               os=-elf
-               ;;
-       or32-*)
-               os=-coff
-               ;;
-       *-tti)  # must be before sparc entry or we get the wrong os.
-               os=-sysv3
-               ;;
-       sparc-* | *-sun)
-               os=-sunos4.1.1
-               ;;
-       *-be)
-               os=-beos
-               ;;
-       *-haiku)
-               os=-haiku
-               ;;
-       *-ibm)
-               os=-aix
-               ;;
-       *-knuth)
-               os=-mmixware
-               ;;
-       *-wec)
-               os=-proelf
-               ;;
-       *-winbond)
-               os=-proelf
-               ;;
-       *-oki)
-               os=-proelf
-               ;;
-       *-hp)
-               os=-hpux
-               ;;
-       *-hitachi)
-               os=-hiux
-               ;;
-       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
-               os=-sysv
-               ;;
-       *-cbm)
-               os=-amigaos
-               ;;
-       *-dg)
-               os=-dgux
-               ;;
-       *-dolphin)
-               os=-sysv3
-               ;;
-       m68k-ccur)
-               os=-rtu
-               ;;
-       m88k-omron*)
-               os=-luna
-               ;;
-       *-next )
-               os=-nextstep
-               ;;
-       *-sequent)
-               os=-ptx
-               ;;
-       *-crds)
-               os=-unos
-               ;;
-       *-ns)
-               os=-genix
-               ;;
-       i370-*)
-               os=-mvs
-               ;;
-       *-next)
-               os=-nextstep3
-               ;;
-       *-gould)
-               os=-sysv
-               ;;
-       *-highlevel)
-               os=-bsd
-               ;;
-       *-encore)
-               os=-bsd
-               ;;
-       *-sgi)
-               os=-irix
-               ;;
-       *-siemens)
-               os=-sysv4
-               ;;
-       *-masscomp)
-               os=-rtu
-               ;;
-       f30[01]-fujitsu | f700-fujitsu)
-               os=-uxpv
-               ;;
-       *-rom68k)
-               os=-coff
-               ;;
-       *-*bug)
-               os=-coff
-               ;;
-       *-apple)
-               os=-macos
-               ;;
-       *-atari*)
-               os=-mint
-               ;;
-       *)
-               os=-none
-               ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer.  We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
-       *-unknown)
-               case $os in
-                       -riscix*)
-                               vendor=acorn
-                               ;;
-                       -sunos*)
-                               vendor=sun
-                               ;;
-                       -aix*)
-                               vendor=ibm
-                               ;;
-                       -beos*)
-                               vendor=be
-                               ;;
-                       -hpux*)
-                               vendor=hp
-                               ;;
-                       -mpeix*)
-                               vendor=hp
-                               ;;
-                       -hiux*)
-                               vendor=hitachi
-                               ;;
-                       -unos*)
-                               vendor=crds
-                               ;;
-                       -dgux*)
-                               vendor=dg
-                               ;;
-                       -luna*)
-                               vendor=omron
-                               ;;
-                       -genix*)
-                               vendor=ns
-                               ;;
-                       -mvs* | -opened*)
-                               vendor=ibm
-                               ;;
-                       -os400*)
-                               vendor=ibm
-                               ;;
-                       -ptx*)
-                               vendor=sequent
-                               ;;
-                       -tpf*)
-                               vendor=ibm
-                               ;;
-                       -vxsim* | -vxworks* | -windiss*)
-                               vendor=wrs
-                               ;;
-                       -aux*)
-                               vendor=apple
-                               ;;
-                       -hms*)
-                               vendor=hitachi
-                               ;;
-                       -mpw* | -macos*)
-                               vendor=apple
-                               ;;
-                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-                               vendor=atari
-                               ;;
-                       -vos*)
-                               vendor=stratus
-                               ;;
-               esac
-               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
-               ;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/lib/replace/configure.ac b/lib/replace/configure.ac
deleted file mode 100644 (file)
index 0361825..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-AC_PREREQ(2.50)
-AC_INIT(replace.c)
-AC_CONFIG_SRCDIR([replace.c])
-AC_CONFIG_HEADER(config.h)
-
-CFLAGS="$CFLAGS -I$srcdir"
-
-AC_LIBREPLACE_ALL_CHECKS
-AC_LIBREPLACE_NETWORK_CHECKS
-
-if test "$ac_cv_prog_gcc" = yes; then
-   CFLAGS="$CFLAGS -Wall"
-   CFLAGS="$CFLAGS -W"
-   CFLAGS="$CFLAGS -Wshadow"
-   CFLAGS="$CFLAGS -Wstrict-prototypes"
-   CFLAGS="$CFLAGS -Wpointer-arith"
-   CFLAGS="$CFLAGS -Wcast-qual"
-   CFLAGS="$CFLAGS -Wcast-align"
-   CFLAGS="$CFLAGS -Wwrite-strings"
-   CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
-   CFLAGS="$CFLAGS -Wformat=2"
-   CFLAGS="$CFLAGS -Wno-format-y2k"
-fi
-
-m4_include(build_macros.m4)
-BUILD_WITH_SHARED_BUILD_DIR
-
-LIBS="${LIBREPLACE_NETWORK_LIBS}"
-AC_SUBST(LIBS)
-
-AC_SUBST(LDFLAGS)
-
-AC_OUTPUT(Makefile)
index ca0c6846ab58bc76d2f72aeede8636e33b5e8667..796069c8ca1603c0ef73b18dfeec1ec25a64f18e 100644 (file)
@@ -49,7 +49,7 @@ fi
 LIBREPLACEOBJ="$libreplacedir/replace.o"
 AC_SUBST(LIBREPLACEOBJ)
 
-LIBREPLACEOBJ="${LIBREPLACEOBJ} $libreplacedir/snprintf.o"
+LIBREPLACEOBJ="${LIBREPLACEOBJ} $libreplacedir/snprintf.o  $libreplacedir/xattr.o"
 
 AC_TYPE_UID_T
 AC_TYPE_MODE_T
@@ -60,6 +60,8 @@ AC_STRUCT_ST_RDEV
 AC_CHECK_TYPE(ino_t,unsigned)
 AC_CHECK_TYPE(loff_t,off_t)
 AC_CHECK_TYPE(offset_t,loff_t)
+AC_CHECK_TYPE(blksize_t,long)
+AC_CHECK_TYPE(blkcnt_t,long)
 
 AC_FUNC_MEMCMP
 
@@ -107,6 +109,13 @@ if test x"$libreplace_cv_HAVE_MREMAP" = x"yes"; then
     AC_DEFINE(HAVE_MREMAP,1,[Whether mremap works])
 fi
 
+AC_CACHE_CHECK([for incoherent mmap],libreplace_cv_HAVE_INCOHERENT_MMAP,[
+AC_TRY_RUN([#include "$libreplacedir/test/incoherent_mmap.c"],
+           libreplace_cv_HAVE_INCOHERENT_MMAP=yes,libreplace_cv_HAVE_INCOHERENT_MMAP=no,libreplace_cv_HAVE_INCOHERENT_MMAP=cross)])
+if test x"$libreplace_cv_HAVE_INCOHERENT_MMAP" = x"yes"; then
+    AC_DEFINE(HAVE_INCOHERENT_MMAP,1,[Whether mmap is incoherent against write])
+fi
+
 
 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
 AC_CHECK_HEADERS(sys/time.h time.h)
@@ -114,9 +123,12 @@ AC_CHECK_HEADERS(stdarg.h vararg.h)
 AC_CHECK_HEADERS(sys/mount.h mntent.h)
 AC_CHECK_HEADERS(stropts.h)
 AC_CHECK_HEADERS(unix.h)
+AC_CHECK_HEADERS(malloc.h)
+AC_CHECK_HEADERS(syscall.h)
+AC_CHECK_HEADERS(sys/syscall.h)
 
-AC_CHECK_FUNCS(seteuid setreuid setresuid setegid setregid setresgid)
-AC_CHECK_FUNCS(chroot bzero strerror strerror_r)
+AC_CHECK_FUNCS(syscall setuid seteuid setreuid setresuid setgid setegid setregid setresgid setgroups)
+AC_CHECK_FUNCS(chroot bzero strerror strerror_r memalign posix_memalign getpagesize)
 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
 AC_CHECK_FUNCS(waitpid wait4 strlcpy strlcat initgroups memmove strdup)
 AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp dup2 dprintf vdprintf)
@@ -134,6 +146,60 @@ AC_CHECK_FUNCS(clock_gettime,libreplace_cv_have_clock_gettime=yes,[
                libreplace_cv_have_clock_gettime=yes
                AC_DEFINE(HAVE_CLOCK_GETTIME, 1, Define to 1 if there is support for clock_gettime)])
 ])
+
+AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
+AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
+
+LIBREPLACE_FILESYS_LIBS=""
+
+############################################
+# Check for EA implementations
+case "$host_os" in
+  *freebsd4* | *dragonfly* )
+       AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
+  ;;
+  *)
+       AC_SEARCH_LIBS(getxattr, [attr])
+       AC_CHECK_FUNCS(attr_get attr_getf attr_list attr_listf attropen attr_remove)
+       AC_CHECK_FUNCS(attr_removef attr_set attr_setf extattr_delete_fd extattr_delete_file)
+       AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_list_fd extattr_list_file)
+       AC_CHECK_FUNCS(extattr_set_fd extattr_set_file fgetea fgetxattr flistea flistxattr)
+       AC_CHECK_FUNCS(fremoveea fremovexattr fsetea fsetxattr getea getxattr listea)
+       AC_CHECK_FUNCS(listxattr removeea removexattr setea setxattr)
+
+       AC_CHECK_LIB_EXT(attr, LIBREPLACE_FILESYS_LIBS, flistea)
+       AC_CHECK_LIB_EXT(attr, LIBREPLACE_FILESYS_LIBS, flistxattr)
+       AC_CHECK_LIB_EXT(attr, LIBREPLACE_FILESYS_LIBS, attr_listf)
+       AC_CHECK_LIB_EXT(attr, LIBREPLACE_FILESYS_LIBS, extattr_list_fd)
+
+  ;;
+esac
+
+
+########################################################
+# Do xattr functions take additional options like on Darwin?
+if test x"$ac_cv_func_getxattr" = x"yes" ; then
+       AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
+               old_LIBS=$LIBS
+               LIBS="$LIBS $LIBREPLACE_FILESYS_LIBS"
+               AC_TRY_COMPILE([
+                       #include <sys/types.h>
+                       #if HAVE_ATTR_XATTR_H
+                       #include <attr/xattr.h>
+                       #elif HAVE_SYS_XATTR_H
+                       #include <sys/xattr.h>
+                       #endif
+               ],[
+                       getxattr(0, 0, 0, 0, 0, 0);
+               ],
+               [smb_attr_cv_xattr_add_opt=yes],
+               [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
+       ])
+       if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
+               AC_DEFINE(XATTR_ADDITIONAL_OPTIONS, 1, [xattr functions have additional options])
+       fi
+fi
+
 AC_CHECK_FUNCS(get_current_dir_name)
 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
@@ -146,12 +212,27 @@ AC_TRY_RUN([#include <stdlib.h>
 #include <unistd.h>
 main() { 
   struct stat st;
-  char tpl[20]="/tmp/test.XXXXXX"; 
-  int fd = mkstemp(tpl); 
-  if (fd == -1) exit(1);
+  char tpl[20]="/tmp/test.XXXXXX";
+  char tpl2[20]="/tmp/test.XXXXXX";
+  int fd = mkstemp(tpl);
+  int fd2 = mkstemp(tpl2);
+  if (fd == -1) {
+        if (fd2 != -1) {
+                unlink(tpl2);
+        }
+        exit(1);
+  }
+  if (fd2 == -1) exit(1);
   unlink(tpl);
+  unlink(tpl2);
   if (fstat(fd, &st) != 0) exit(1);
   if ((st.st_mode & 0777) != 0600) exit(1);
+  if (strcmp(tpl, "/tmp/test.XXXXXX") == 0) {
+        exit(1);
+  }
+  if (strcmp(tpl, tpl2) == 0) {
+        exit(1);
+  }
   exit(0);
 }],
 libreplace_cv_HAVE_SECURE_MKSTEMP=yes,
index 7ddc19f14bb47d4c9690e73a48f1923c42f52600..50cb73583ba377a7c00f86cec1feed98257827fd 100644 (file)
@@ -50,11 +50,21 @@ AC_PROG_INSTALL
 AC_ISC_POSIX
 AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED)
 
+AC_MSG_CHECKING(checking getconf LFS_CFLAGS for large file support flags)
+LFS_CFLAGS=`(getconf LFS_CFLAGS) 2>/dev/null` || LFS_CFLAGS=""
+
+AC_MSG_RESULT(${LFS_CFLAGS})
+if test "x$LFS_CFLAGS" != 'x-1' || test "x$LFS_CFLAGS" != "xundefined"; then
+   CFLAGS="$CFLAGS $LFS_CFLAGS"
+fi
+
 AC_SYS_LARGEFILE
 
 dnl Add #include for broken IRIX header files
 case "$host_os" in
        *irix6*) AC_ADD_INCLUDE(<standards.h>)
+               AC_N_DEFINE(_XOPEN_SOURCE,600)
+               AC_N_DEFINE(_BSD_TYPES)
                ;;
        *hpux*)
                # mmap on HPUX is completely broken...
index eadcc6bfc11a153415e99cdd2ee149d5bfca5f29..bb2a84324eb47f783942cd0dd482bb9731483932 100644 (file)
@@ -473,6 +473,30 @@ fi
 LIBS=$old_LIBS
 CPPFLAGS="$libreplace_SAVE_CPPFLAGS"
 
+AC_CACHE_CHECK([for SO_PEERCRED],libreplace_cv_HAVE_PEERCRED,[
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>],
+[struct ucred cred;
+ socklen_t cred_len;
+ int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
+],
+libreplace_cv_HAVE_PEERCRED=yes,libreplace_cv_HAVE_PEERCRED=no,libreplace_cv_HAVE_PEERCRED=cross)])
+if test x"$libreplace_cv_HAVE_PEERCRED" = x"yes"; then
+    AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
+fi
+
+AC_CACHE_CHECK([for getpeereid],libreplace_cv_HAVE_GETPEEREID,[
+AC_TRY_LINK([#include <sys/types.h>
+#include <unistd.h>],
+[uid_t uid; gid_t gid; int ret;
+ ret = getpeereid(0, &uid, &gid);
+],
+libreplace_cv_HAVE_GETPEEREID=yes,libreplace_cv_HAVE_GETPEEREID=no)])
+if test x"$libreplace_cv_HAVE_GETPEEREID" = xyes; then
+   AC_DEFINE(HAVE_GETPEEREID,1,
+            [Whether we have getpeereid to get socket credentials])
+fi
+
 LIBREPLACEOBJ="${LIBREPLACEOBJ} ${LIBREPLACE_NETWORK_OBJS}"
 
 echo "LIBREPLACE_NETWORK_CHECKS: END"
index e41548dd39f5b9509def73e412ec0ef8f134a50c..1105617b63b56d2d5b979d883bbd4e2c4e6f6f5e 100644 (file)
 
 #include "replace.h"
 #include "system/select.h"
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
 
 
 int rep_poll(struct pollfd *fds, nfds_t nfds, int timeout)
@@ -40,7 +46,7 @@ int rep_poll(struct pollfd *fds, nfds_t nfds, int timeout)
        int rc;
        nfds_t i;
 
-       if (fds == NULL) {
+       if ((fds == NULL) && (nfds != 0)) {
                errno = EFAULT;
                return -1;
        }
index a522853351ceb9a32cf0a0c7574a3ff64efc70f1..ed8e75e3b113026ae8dc40a2e5b5fcf52d5fa850 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef __LIB_REPLACE_REPLACE_TEST_H__
 #define __LIB_REPLACE_REPLACE_TEST_H__
 
-#include <stdbool.h>
-struct torture_context;
-
-bool torture_local_replace(struct torture_context *ctx);
 int libreplace_test_strptime(void);
 int test_readdir_os2_delete(void);
 int getifaddrs_test(void);
diff --git a/lib/replace/replace-testsuite.h b/lib/replace/replace-testsuite.h
new file mode 100644 (file)
index 0000000..b28dbec
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __LIB_REPLACE_REPLACE_TESTSUITE_H__
+#define __LIB_REPLACE_REPLACE_TESTSUITE_H__
+
+#include <stdbool.h>
+struct torture_context;
+
+bool torture_local_replace(struct torture_context *ctx);
+
+#endif /* __LIB_REPLACE_REPLACE_TESTSUITE_H__ */
+
index d9a96ff8ef9219e92cd7ed09b3971b60c6da16f0..e461471e5517340f8e414d4193774cef7fc43987 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "system/filesys.h"
 #include "system/time.h"
+#include "system/network.h"
 #include "system/passwd.h"
 #include "system/syslog.h"
 #include "system/locale.h"
@@ -213,16 +214,6 @@ int rep_initgroups(char *name, gid_t id)
 #endif /* HAVE_INITGROUPS */
 
 
-#if (defined(SecureWare) && defined(SCO))
-/* This is needed due to needing the nap() function but we don't want
-   to include the Xenix libraries since that will break other things...
-   BTW: system call # 0x0c28 is the same as calling nap() */
-long nap(long milliseconds) {
-        return syscall(0x0c28, milliseconds);
- }
-#endif
-
-
 #ifndef HAVE_MEMMOVE
 /*******************************************************************
 safely copies memory, ensuring no overlap problems.
@@ -411,8 +402,8 @@ int rep_mkstemp(char *template)
 {
        /* have a reasonable go at emulating it. Hope that
           the system mktemp() isn't completely hopeless */
-       char *p = mktemp(template);
-       if (!p)
+       mktemp(template);
+       if (template[0] == 0)
                return -1;
        return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
 }
@@ -828,3 +819,84 @@ int rep_clock_gettime(clockid_t clk_id, struct timespec *tp)
        return 0;
 }
 #endif
+
+#ifndef HAVE_MEMALIGN
+void *rep_memalign( size_t align, size_t size )
+{
+#if defined(HAVE_POSIX_MEMALIGN)
+       void *p = NULL;
+       int ret = posix_memalign( &p, align, size );
+       if ( ret == 0 )
+               return p;
+
+       return NULL;
+#else
+       /* On *BSD systems memaligns doesn't exist, but memory will
+        * be aligned on allocations of > pagesize. */
+#if defined(SYSCONF_SC_PAGESIZE)
+       size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
+#elif defined(HAVE_GETPAGESIZE)
+       size_t pagesize = (size_t)getpagesize();
+#else
+       size_t pagesize = (size_t)-1;
+#endif
+       if (pagesize == (size_t)-1) {
+               errno = ENOSYS;
+               return NULL;
+       }
+       if (size < pagesize) {
+               size = pagesize;
+       }
+       return malloc(size);
+#endif
+}
+#endif
+
+#ifndef HAVE_GETPEEREID
+int rep_getpeereid(int s, uid_t *uid, gid_t *gid)
+{
+#if defined(HAVE_PEERCRED)
+       struct ucred cred;
+       socklen_t cred_len = sizeof(struct ucred);
+       int ret;
+
+#undef getsockopt
+       ret = getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void *)&cred, &cred_len);
+       if (ret != 0) {
+               return -1;
+       }
+
+       if (cred_len != sizeof(struct ucred)) {
+               errno = EINVAL;
+               return -1;
+       }
+
+       *uid = cred.uid;
+       *gid = cred.gid;
+       return 0;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+#endif
+
+#ifndef HAVE_USLEEP
+int rep_usleep(useconds_t sec)
+{
+       struct timeval tval;
+       /*
+        * Fake it with select...
+        */
+       tval.tv_sec = 0;
+       tval.tv_usec = usecs/1000;
+       select(0,NULL,NULL,NULL,&tval);
+       return 0;
+}
+#endif /* HAVE_USLEEP */
+
+#ifndef HAVE_SETPROCTITLE
+void rep_setproctitle(const char *fmt, ...)
+{
+}
+#endif
index 711241462ead25563aadab1a5d0af6152c5c6901..bbea0fc77481057e7c08b16e06f6fa874752bead 100644 (file)
 #include <inttypes.h>
 #endif
 
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
 #ifndef __PRI64_PREFIX
-# if __WORDSIZE == 64
+# if __WORDSIZE == 64 && ! defined __APPLE__
 #  define __PRI64_PREFIX       "l"
 # else
 #  define __PRI64_PREFIX       "ll"
 #include <bsd/string.h>
 #endif
 
+#ifdef HAVE_BSD_UNISTD_H
+#include <bsd/unistd.h>
+#endif
+
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
 #include <sys/types.h>
 #endif
 
+#ifdef HAVE_SETPROCTITLE_H
+#include <setproctitle.h>
+#endif
+
 #if STDC_HEADERS
 #include <stdlib.h>
 #include <stddef.h>
@@ -157,6 +169,11 @@ void *rep_memmem(const void *haystack, size_t haystacklen,
                 const void *needle, size_t needlelen);
 #endif
 
+#ifndef HAVE_MEMALIGN
+#define memalign rep_memalign
+void *rep_memalign(size_t boundary, size_t size);
+#endif
+
 #ifndef HAVE_MKTIME
 #define mktime rep_mktime
 /* prototype is in "system/time.h" */
@@ -438,7 +455,7 @@ void rep_vsyslog (int facility_priority, const char *format, va_list arglist) PR
 typedef int (*comparison_fn_t)(const void *, const void *);
 #endif
 
-#ifdef REPLACE_STRPTIME
+#ifndef HAVE_WORKING_STRPTIME
 #define strptime rep_strptime
 struct tm;
 char *rep_strptime(const char *buf, const char *format, struct tm *tm);
@@ -573,6 +590,10 @@ int rep_strerror_r(int errnum, char *buf, size_t buflen);
 #define UINT64_MAX ((uint64_t)-1)
 #endif
 
+#ifndef INT64_MAX
+#define INT64_MAX 9223372036854775807LL
+#endif
+
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
@@ -817,4 +838,20 @@ char *rep_getpass(const char *prompt);
 #endif
 #endif
 
+#ifndef HAVE_GETPEEREID
+#define getpeereid rep_getpeereid
+int rep_getpeereid(int s, uid_t *uid, gid_t *gid);
+#endif
+
+#ifndef HAVE_USLEEP
+#define usleep rep_usleep
+typedef long useconds_t;
+int usleep(useconds_t);
+#endif
+
+#ifndef HAVE_SETPROCTITLE
+#define setproctitle rep_setproctitle
+void rep_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
+#endif
+
 #endif /* _LIBREPLACE_REPLACE_H */
diff --git a/lib/replace/samba.m4 b/lib/replace/samba.m4
deleted file mode 100644 (file)
index b758220..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-AC_LIBREPLACE_BROKEN_CHECKS
-AC_LIBREPLACE_NETWORK_CHECKS
-
-SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL} ${CRYPT_LIBS}])
-SMB_ENABLE(LIBREPLACE_EXT)
-
-SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}])
-SMB_ENABLE(LIBREPLACE_NETWORK)
-
-# remove leading ./
-LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'`
-
-# remove leading srcdir .. we are looking for the relative
-# path within the samba source tree or wherever libreplace is.
-# We need to make sure the object is not forced to end up in
-# the source directory because we might be using a separate
-# build directory.
-LIBREPLACE_DIR=`echo ${LIBREPLACE_DIR} | sed -e "s|^$srcdir/||g"`
-
-LIBREPLACE_OBJS="${LIBREPLACEOBJ}"
-
-SMB_SUBSYSTEM(LIBREPLACE,
-       [${LIBREPLACE_OBJS}],
-       [LIBREPLACE_EXT LIBREPLACE_NETWORK],
-       [-Ilib/replace])
-
-LIBREPLACE_HOSTCC_OBJS=`echo ${LIBREPLACE_OBJS} |sed -e 's/\.o/\.ho/g'`
-
-SMB_SUBSYSTEM(LIBREPLACE_HOSTCC,
-       [${LIBREPLACE_HOSTCC_OBJS}],
-       [],
-       [-Ilib/replace])
-
-AC_CHECK_FUNCS([syslog],,[AC_MSG_ERROR([Required function not found])])
index bca774263ef3cb2555610e10a5c4386ebe387df7..877d2a1d62b8f46eadd7c6be9cce140d340e21c6 100644 (file)
@@ -1187,7 +1187,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
        return max;
 }
 
- int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
+ int rep_vsnprintf (char *str, size_t count, const char *fmt, va_list args)
 {
        return dopr(str, count, fmt, args);
 }
@@ -1200,7 +1200,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
  * that doesn't work properly according to the autoconf test.
  */
 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
- int snprintf(char *str,size_t count,const char *fmt,...)
+ int rep_snprintf(char *str,size_t count,const char *fmt,...)
 {
        size_t ret;
        va_list ap;
@@ -1213,7 +1213,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
 #endif
 
 #ifndef HAVE_C99_VSNPRINTF
- int printf(const char *fmt, ...)
+ int rep_printf(const char *fmt, ...)
 {
        va_list ap;
        int ret;
@@ -1234,7 +1234,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
 #endif
 
 #ifndef HAVE_C99_VSNPRINTF
- int fprintf(FILE *stream, const char *fmt, ...)
+ int rep_fprintf(FILE *stream, const char *fmt, ...)
 {
        va_list ap;
        int ret;
@@ -1257,7 +1257,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
 #endif 
 
 #ifndef HAVE_VASPRINTF
- int vasprintf(char **ptr, const char *format, va_list ap)
+ int rep_vasprintf(char **ptr, const char *format, va_list ap)
 {
        int ret;
        va_list ap2;
@@ -1280,7 +1280,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
 
 
 #ifndef HAVE_ASPRINTF
- int asprintf(char **ptr, const char *format, ...)
+ int rep_asprintf(char **ptr, const char *format, ...)
 {
        va_list ap;
        int ret;
index 0e40f7561acd72e1e2b3cfb11393331a44f67d1a..20e5d8c39b6a2acc0189ad8fcb5ddf11285b0f52 100644 (file)
@@ -251,7 +251,6 @@ strptime_internal (rp, fmt, tm, decided, era_cnt)
      enum locale_status *decided;
      int era_cnt;
 {
-  const char *rp_backup;
   int cnt;
   size_t val;
   int have_I, is_pm;
@@ -261,15 +260,17 @@ strptime_internal (rp, fmt, tm, decided, era_cnt)
   int have_yday;
   int have_mon, have_mday;
 #ifdef _NL_CURRENT
+  const char *rp_backup;
   size_t num_eras;
-#endif
   struct era_entry *era;
 
+  era = NULL;
+#endif
+
   have_I = is_pm = 0;
   century = -1;
   want_century = 0;
   want_era = 0;
-  era = NULL;
 
   have_wday = want_xday = have_yday = have_mon = have_mday = 0;
 
@@ -299,8 +300,10 @@ strptime_internal (rp, fmt, tm, decided, era_cnt)
     start_over:
 #endif
 
+#ifdef _NL_CURRENT
       /* Make back up of current processing pointer.  */
       rp_backup = rp;
+#endif
 
       switch (*fmt++)
        {
index b1a56b4aab17cc8f094edb65ecab5b16b81c48de..8ac22f63426a4662d7b90bce2e128b2504612039 100644 (file)
@@ -1,3 +1,5 @@
+AC_CHECK_FUNCS(strptime)
+AC_CHECK_DECLS(strptime, [], [], [#include <time.h>])
 AC_CACHE_CHECK([whether strptime is available and works],libreplace_cv_STRPTIME_OK,[
        AC_TRY_RUN([
                #define LIBREPLACE_CONFIGURE_TEST_STRPTIME
@@ -8,6 +10,7 @@ AC_CACHE_CHECK([whether strptime is available and works],libreplace_cv_STRPTIME_
                [libreplace_cv_STRPTIME_OK="assuming not"])
 ])
 if test x"$libreplace_cv_STRPTIME_OK" != x"yes"; then
-        AC_DEFINE(REPLACE_STRPTIME,1,[Whether strptime should be replaced])
         LIBREPLACEOBJ="${LIBREPLACEOBJ} $libreplacedir/strptime.o"
+else
+        AC_DEFINE(HAVE_WORKING_STRPTIME,1,[Whether strptime is working correct])
 fi
index e2c3c1dd7250896ae04014ef74442f07c9218d43..c8ac2b4f748738f7dd82594ec6c99cba87b01344 100644 (file)
 
 #if HAVE_SYS_ATTRIBUTES_H
 #include <sys/attributes.h>
+#elif HAVE_ATTR_ATTRIBUTES_H
+#include <attr/attributes.h>
 #endif
 
 /* mutually exclusive (SuSE 8.2) */
 #include <sys/xattr.h>
 #endif
 
+#ifdef HAVE_SYS_EA_H
+#include <sys/ea.h>
+#endif
+
+#ifdef HAVE_SYS_EXTATTR_H
+#include <sys/extattr.h>
+#endif
 
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
 
+#ifndef XATTR_CREATE
+#define XATTR_CREATE  0x1       /* set value, fail if attr already exists */
+#endif
+
+#ifndef XATTR_REPLACE
+#define XATTR_REPLACE 0x2       /* set value, fail if attr does not exist */
+#endif
+
 /* Some POSIX definitions for those without */
 
 #ifndef S_IFDIR
 # define uwrap_enabled() 0
 #endif /* UID_WRAPPER */
 
+/*
+   this allows us to use a uniform error handling for our xattr
+   wrappers
+*/
+#ifndef ENOATTR
+#define ENOATTR ENODATA
+#endif
+
+
+#if !defined(HAVE_GETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t size);
+#define getxattr(path, name, value, size) rep_getxattr(path, name, value, size)
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_FGETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size);
+#define fgetxattr(filedes, name, value, size) rep_fgetxattr(filedes, name, value, size)
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_LISTXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+ssize_t rep_listxattr (const char *path, char *list, size_t size);
+#define listxattr(path, list, size) rep_listxattr(path, list, size)
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_FLISTXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+ssize_t rep_flistxattr (int filedes, char *list, size_t size);
+#define flistxattr(filedes, value, size) rep_flistxattr(filedes, value, size)
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_REMOVEXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+int rep_removexattr (const char *path, const char *name);
+#define removexattr(path, name) rep_removexattr(path, name)
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_FREMOVEXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+int rep_fremovexattr (int filedes, const char *name);
+#define fremovexattr(filedes, name) rep_fremovexattr(filedes, name)
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_SETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+int rep_setxattr (const char *path, const char *name, const void *value, size_t size, int flags);
+#define setxattr(path, name, value, size, flags) rep_setxattr(path, name, value, size, flags)
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_FSETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
+#define fsetxattr(filedes, name, value, size, flags) rep_fsetxattr(filedes, name, value, size, flags)
+/* define is in "replace.h" */
+#endif
+
 #endif
diff --git a/lib/replace/system/gssapi.h b/lib/replace/system/gssapi.h
new file mode 100644 (file)
index 0000000..6386c7b
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef _system_gssapi_h
+#define _system_gssapi_h
+
+/*
+   Unix SMB/CIFS implementation.
+
+   GSSAPI system include wrappers
+
+   Copyright (C) Andrew Tridgell 2004
+
+     ** NOTE! The following LGPL license applies to the replace
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifdef HAVE_GSSAPI
+
+#ifdef HAVE_GSSAPI_GSSAPI_EXT_H
+#include <gssapi/gssapi_ext.h>
+#elif HAVE_GSSAPI_GSSAPI_H
+#include <gssapi/gssapi.h>
+#elif HAVE_GSSAPI_GSSAPI_GENERIC_H
+#include <gssapi/gssapi_generic.h>
+#elif HAVE_GSSAPI_H
+#include <gssapi.h>
+#endif
+
+#if HAVE_GSSAPI_GSSAPI_KRB5_H
+#include <gssapi/gssapi_krb5.h>
+#endif
+
+#if HAVE_GSSAPI_GSSAPI_SPNEGO_H
+#include <gssapi/gssapi_spnego.h>
+#elif HAVE_GSSAPI_SPNEGO_H
+#include <gssapi_spnego.h>
+#endif
+
+#endif
+#endif
index 7762d4be46910f7b9d285c9da8b7da6d0f738a29..636ce0f2e0bff273b332f3704abf7501854845e6 100644 (file)
@@ -7,11 +7,11 @@
    kerberos system include wrappers
 
    Copyright (C) Andrew Tridgell 2004
-   
+
      ** NOTE! The following LGPL license applies to the replace
      ** library. This does NOT imply that all of Samba is released
      ** under the LGPL
-   
+
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
 #include <com_err.h>
 #endif
 
-#ifdef HAVE_GSSAPI_GSSAPI_EXT_H
-#include <gssapi/gssapi_ext.h>
-#elif HAVE_GSSAPI_GSSAPI_H
-#include <gssapi/gssapi.h>
-#elif HAVE_GSSAPI_GSSAPI_GENERIC_H
-#include <gssapi/gssapi_generic.h>
-#elif HAVE_GSSAPI_H
-#include <gssapi.h>
-#endif
-
-#if HAVE_GSSAPI_GSSAPI_KRB5_H
-#include <gssapi/gssapi_krb5.h>
-#endif
-
 #endif
 #endif
diff --git a/lib/replace/test/incoherent_mmap.c b/lib/replace/test/incoherent_mmap.c
new file mode 100644 (file)
index 0000000..ee288fd
--- /dev/null
@@ -0,0 +1,83 @@
+/* In OpenBSD, if you write to a file, another process doesn't see it
+ * in its mmap.  Returns with exit status 0 if that is the case, 1 if
+ * it's coherent, and other if there's a problem. */
+#include <err.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#define DATA "coherent.mmap"
+
+int main(int argc, char *argv[])
+{
+       int tochild[2], toparent[2];
+       int fd;
+       volatile unsigned char *map;
+       unsigned char *page;
+        const char *fname = argv[1];
+       char c = 0;
+
+       if (pipe(tochild) != 0 || pipe(toparent) != 0)
+               err(2, "Creating pipe");
+
+       if (!fname)
+               fname = DATA;
+
+       fd = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0600);
+       if (fd < 0)
+               err(2, "opening %s", fname);
+       unlink(fname);
+
+       switch (fork()) {
+       case -1:
+               err(2, "Fork");
+       case 0:
+               close(tochild[1]);
+               close(toparent[0]);
+
+               /* Wait for parent to create file. */
+               if (read(tochild[0], &c, 1) != 1)
+                       err(2, "reading from parent");
+
+               /* Alter first byte. */
+               pwrite(fd, &c, 1, 0);
+
+               if (write(toparent[1], &c, 1) != 1)
+                       err(2, "writing to parent");
+               exit(0);
+
+       default:
+               close(tochild[0]);
+               close(toparent[1]);
+
+               /* Create a file and mmap it. */
+               page = malloc(getpagesize());
+               memset(page, 0x42, getpagesize());
+               if (write(fd, page, getpagesize()) != getpagesize())
+                       err(2, "writing first page");
+               map = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE,
+                          MAP_SHARED, fd, 0);
+               if (map == MAP_FAILED)
+                       err(2, "mapping file");
+
+               if (*map != 0x42)
+                       errx(2, "first byte isn't 0x42!");
+
+               /* Tell child to alter file. */
+               if (write(tochild[1], &c, 1) != 1)
+                       err(2, "writing to child");
+
+               if (read(toparent[0], &c, 1) != 1)
+                       err(2, "reading from child");
+
+               if (*map)
+                       errx(0, "mmap incoherent: first byte isn't 0.");
+
+               exit(1);
+       }
+}
index 9bd12840a5b4ad5e52c14585a06b0f8e24ea7bde..94264d73672a38a68fc5d74f98f0a2da78be921e 100644 (file)
@@ -24,9 +24,7 @@
 */
 
 #include "replace.h"
-
-struct torture_context;
-bool torture_local_replace(struct torture_context *ctx);
+#include "replace-testsuite.h"
 
 int main(void)
 {
index 0c1fac67a0e54b3ab726f5c0cb43708d2af03cac..04658bea05975b7d1d9f394bac923ffbea6e0b36 100644 (file)
@@ -24,6 +24,8 @@
 */
 
 #include "replace.h"
+#include "replace-test.h"
+#include "replace-testsuite.h"
 
 /*
   we include all the system/ include files here so that libreplace tests
@@ -48,8 +50,6 @@
 
 #define TESTFILE "testfile.dat"
 
-struct torture_context;
-bool torture_local_replace(struct torture_context *ctx);
 
 /*
   test ftruncate() function
@@ -379,8 +379,6 @@ static int test_opendir(void)
        return true;
 }
 
-extern int test_readdir_os2_delete(void);
-
 static int test_readdir(void)
 {
        printf("test: readdir\n");
index 5bafc1fe9f7a46e17061fae3dfbc1470b2f6bfcd..732c664b6ef8907511eef7a568a794ba0d10f926 100644 (file)
@@ -38,12 +38,36 @@ def configure(conf):
         conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True)
         conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
 
+    # SCM_RIGHTS is only avail if _XOPEN_SOURCE iÑ• defined on IRIX
+    if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX':
+        conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
+        conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True)
+
+    # Try to find the right extra flags for C99 initialisers
+    for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]:
+        if conf.CHECK_CFLAGS([f], '''
+struct foo {int x;char y;};
+struct foo bar = { .y = 'X', .x = 1 };
+'''):
+            if f != "":
+                conf.ADD_CFLAGS(f)
+            break
+
+    # Try to find the right extra flags for -Werror behaviour
+    for f in ["-Werror", "-w2", "-errwarn"]:
+        if conf.CHECK_CFLAGS([f], '''
+'''):
+            if not 'WERROR_CFLAGS' in conf.env:
+                conf.env['WERROR_CFLAGS'] = []
+            conf.env['WERROR_CFLAGS'].extend([f])
+            break
+
     conf.CHECK_HEADERS('linux/types.h crypt.h locale.h acl/libacl.h compat.h')
     conf.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h')
     conf.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h')
     conf.CHECK_HEADERS('libaio.h locale.h ndir.h pwd.h')
     conf.CHECK_HEADERS('shadow.h sys/acl.h')
-    conf.CHECK_HEADERS('sys/attributes.h sys/capability.h sys/dir.h sys/epoll.h')
+    conf.CHECK_HEADERS('sys/attributes.h attr/attributes.h sys/capability.h sys/dir.h sys/epoll.h')
     conf.CHECK_HEADERS('sys/fcntl.h sys/filio.h sys/filsys.h sys/fs/s5param.h sys/fs/vx/quota.h')
     conf.CHECK_HEADERS('sys/id.h sys/ioctl.h sys/ipc.h sys/mman.h sys/mode.h sys/ndir.h sys/priv.h')
     conf.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
@@ -60,7 +84,7 @@ def configure(conf):
     conf.CHECK_HEADERS('libintl.h errno.h')
     conf.CHECK_HEADERS('gcrypt.h getopt.h iconv.h')
     conf.CHECK_HEADERS('sys/inotify.h memory.h nss.h sasl/sasl.h')
-    conf.CHECK_HEADERS('security/pam_appl.h sys/inotify.h zlib.h asm/unistd.h')
+    conf.CHECK_HEADERS('security/pam_appl.h zlib.h asm/unistd.h')
     conf.CHECK_HEADERS('aio.h sys/unistd.h rpc/rpc.h rpc/nettype.h alloca.h float.h')
 
     conf.CHECK_HEADERS('rpcsvc/nis.h rpcsvc/ypclnt.h sys/prctl.h sys/sysctl.h')
@@ -69,7 +93,7 @@ def configure(conf):
     conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
     conf.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h')
     conf.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h')
-    conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h')
+    conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h malloc.h')
     conf.CHECK_HEADERS('syscall.h sys/syscall.h inttypes.h')
 
     conf.CHECK_TYPES('"long long" intptr_t uintptr_t ptrdiff_t comparison_fn_t')
@@ -91,6 +115,8 @@ def configure(conf):
     conf.CHECK_TYPE('offset_t', 'loff_t')
     conf.CHECK_TYPE('volatile int', define='HAVE_VOLATILE')
     conf.CHECK_TYPE('uint_t', 'unsigned int')
+    conf.CHECK_TYPE('blksize_t', 'long', headers='sys/types.h sys/stat.h unistd.h')
+    conf.CHECK_TYPE('blkcnt_t', 'long', headers='sys/types.h sys/stat.h unistd.h')
 
     conf.CHECK_SIZEOF('bool char int "long long" long short size_t ssize_t')
     conf.CHECK_SIZEOF('int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t')
@@ -161,19 +187,31 @@ def configure(conf):
 
     conf.CHECK_FUNCS('shl_load shl_unload shl_findsym')
     conf.CHECK_FUNCS('pipe strftime srandom random srand rand usleep setbuffer')
-    conf.CHECK_FUNCS('lstat getpgrp utime utimes seteuid setreuid setresuid setegid')
+    conf.CHECK_FUNCS('lstat getpgrp utime utimes setuid seteuid setreuid setresuid setgid setegid')
     conf.CHECK_FUNCS('setregid setresgid chroot strerror vsyslog setlinebuf mktime')
     conf.CHECK_FUNCS('ftruncate chsize rename waitpid wait4')
     conf.CHECK_FUNCS('initgroups pread pwrite strndup strcasestr')
     conf.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown')
     conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf')
     conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
-    conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq')
+    conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memalign posix_memalign')
 
     # libbsd on some platforms provides strlcpy and strlcat
     if not conf.CHECK_FUNCS('strlcpy strlcat'):
         conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
                 checklibc=True)
+    if not conf.CHECK_FUNCS('getpeereid'):
+        conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
+    if not conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h'):
+        conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h')
+
+    conf.CHECK_CODE('''
+                struct ucred cred;
+                socklen_t cred_len;
+                int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);''',
+                'HAVE_PEERCRED',
+                msg="Checking whether we can use SO_PEERCRED to get socket credentials",
+                headers='sys/types.h sys/socket.h')
 
     #Some OS (ie. freebsd) return EINVAL if the convertion could not be done, it's not what we expect
     #Let's detect those cases
@@ -195,10 +233,44 @@ def configure(conf):
     conf.CHECK_FUNCS('if_nametoindex strerror_r')
     conf.CHECK_FUNCS('getdirentries getdents syslog')
     conf.CHECK_FUNCS('gai_strerror get_current_dir_name')
-    conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs mmap setgroups setsid')
+    conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs mmap setgroups syscall setsid')
     conf.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize')
     conf.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create')
 
+    conf.SET_TARGET_TYPE('attr', 'EMPTY')
+
+    xattr_headers='sys/attributes.h attr/xattr.h sys/xattr.h'
+
+    conf.CHECK_FUNCS_IN('''
+fgetxattr flistea flistxattr
+fremovexattr fsetxattr getxattr
+listxattr removexattr setxattr
+''', 'attr', checklibc=True, headers=xattr_headers)
+
+    # We need to check for linux xattrs first, as we do not wish to link to -lattr
+    # (the XFS compat API) on Linux systems with the native xattr API
+    if not conf.CONFIG_SET('HAVE_GETXATTR'):
+        conf.CHECK_FUNCS_IN('''
+attr_get attr_getf attr_list attr_listf attropen attr_remove
+attr_removef attr_set attr_setf extattr_delete_fd extattr_delete_file
+extattr_get_fd extattr_get_file extattr_list_fd extattr_list_file
+extattr_set_fd extattr_set_file fgetea flistea
+fremoveea fsetea getea listea
+removeea setea
+''', 'attr', checklibc=True, headers=xattr_headers)
+
+    if (conf.CONFIG_SET('HAVE_ATTR_LISTF') or
+        conf.CONFIG_SET('HAVE_EXTATTR_LIST_FD') or
+        conf.CONFIG_SET('HAVE_FLISTEA') or
+        conf.CONFIG_SET('HAVE_FLISTXATTR')):
+            conf.DEFINE('HAVE_XATTR_SUPPORT', 1)
+
+    # Darwin has extra options to xattr-family functions
+    conf.CHECK_CODE('getxattr(NULL, NULL, NULL, 0, 0, 0)',
+                    headers=xattr_headers, local_include=False,
+                    define='XATTR_ADDITIONAL_OPTIONS',
+                    msg="Checking whether xattr interface takes additional options")
+
     conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl',
                         checklibc=True, headers='dlfcn.h dl.h')
 
@@ -265,40 +337,40 @@ def configure(conf):
     conf.CHECK_HEADERS('poll.h')
     conf.CHECK_FUNCS('poll')
 
-    if not conf.CHECK_CODE('''#define LIBREPLACE_CONFIGURE_TEST_STRPTIME
-                           #include "test/strptime.c"''',
-                           define='HAVE_STRPTIME',
-                           addmain=False,
-                           msg='Checking for working strptime'):
-        conf.DEFINE('REPLACE_STRPTIME', 1)
-    else:
-       conf.CHECK_CODE('''
-                        const char *s = "20070414101546Z";
-                        char *ret;
-                        struct tm t;
-                        memset(&t, 0, sizeof(t));
-                        ret = strptime(s, "%Y%m%d%H%M%S", &t);
-                        if (ret == NULL || t.tm_wday != 6) {
-                            return 0;
-                        } else {
-                            return 1;
-                        }
-                        ''',
-                        msg="Checking correct behavior of strptime",
-                        headers = 'time.h',
-                        execute = True,
-                        define_ret = True,
-                        define = 'REPLACE_STRPTIME',
-                        )
+    conf.CHECK_FUNCS('strptime')
+    conf.CHECK_DECLS('strptime', headers='time.h')
+    conf.CHECK_CODE('''#define LIBREPLACE_CONFIGURE_TEST_STRPTIME
+                       #include "test/strptime.c"''',
+                       define='HAVE_WORKING_STRPTIME',
+                       execute=True,
+                       addmain=False,
+                       msg='Checking for working strptime')
 
     conf.CHECK_CODE('gettimeofday(NULL, NULL)', 'HAVE_GETTIMEOFDAY_TZ', execute=False)
 
     conf.CHECK_CODE('#include "test/snprintf.c"',
                     define="HAVE_C99_VSNPRINTF",
-                    execute=1,
+                    execute=True,
                     addmain=False,
                     msg="Checking for C99 vsnprintf")
 
+    conf.CHECK_CODE('#include "test/shared_mmap.c"',
+                    addmain=False, add_headers=False, execute=True,
+                    define='HAVE_SHARED_MMAP',
+                    msg="Checking for HAVE_SHARED_MMAP")
+
+    conf.CHECK_CODE('#include "test/shared_mremap.c"',
+                    addmain=False, add_headers=False, execute=True,
+                    define='HAVE_MREMAP',
+                    msg="Checking for HAVE_MREMAP")
+
+    # OpenBSD (and I've heard HPUX) doesn't sync between mmap and write.
+    # FIXME: Anything other than a 0 or 1 exit code should abort configure!
+    conf.CHECK_CODE('#include "test/incoherent_mmap.c"',
+                    addmain=False, add_headers=False, execute=True,
+                    define='HAVE_INCOHERENT_MMAP',
+                    msg="Checking for HAVE_INCOHERENT_MMAP")
+
     conf.SAMBA_BUILD_ENV()
 
     conf.CHECK_CODE('''
@@ -348,11 +420,26 @@ def configure(conf):
     conf.CHECK_CODE('''
                     struct stat st;
                     char tpl[20]="/tmp/test.XXXXXX";
+                    char tpl2[20]="/tmp/test.XXXXXX";
                     int fd = mkstemp(tpl);
-                    if (fd == -1) exit(1);
+                    int fd2 = mkstemp(tpl2);
+                    if (fd == -1) {
+                          if (fd2 != -1) {
+                                  unlink(tpl2);
+                          }
+                          exit(1);
+                    }
+                    if (fd2 == -1) exit(1);
                     unlink(tpl);
+                    unlink(tpl2);
                     if (fstat(fd, &st) != 0) exit(1);
                     if ((st.st_mode & 0777) != 0600) exit(1);
+                    if (strcmp(tpl, "/tmp/test.XXXXXX") == 0) {
+                          exit(1);
+                    }
+                    if (strcmp(tpl, tpl2) == 0) {
+                          exit(1);
+                    }
                     exit(0);
                     ''',
                     define='HAVE_SECURE_MKSTEMP',
@@ -412,7 +499,12 @@ REPLACEMENT_FUNCTIONS = {
                   'dprintf', 'get_current_dir_name',
                   'strerror_r', 'clock_gettime'],
     'timegm.c': ['timegm'],
-    'snprintf.c': ['snprintf'],
+    # Note: C99_VSNPRINTF is not a function, but a special condition
+    # for replacement
+    'snprintf.c': ['C99_VSNPRINTF', 'snprintf', 'vsnprintf', 'asprintf', 'vasprintf'],
+    # Note: WORKING_STRPTIME is not a function, but a special condition
+    # for replacement
+    'strptime.c': ['WORKING_STRPTIME', 'strptime'],
     }
 
 
@@ -421,19 +513,22 @@ def build(bld):
 
     REPLACE_HOSTCC_SOURCE = ''
 
-    if bld.CONFIG_SET('REPLACE_STRPTIME'):       REPLACE_HOSTCC_SOURCE += ' strptime.c'
     for filename, functions in REPLACEMENT_FUNCTIONS.iteritems():
         for function in functions:
             if not bld.CONFIG_SET('HAVE_%s' % function.upper()):
                 REPLACE_HOSTCC_SOURCE += ' %s' % filename
                 break
 
+    extra_libs = ''
+    if bld.CONFIG_SET('HAVE_LIBBSD'): extra_libs += ' bsd'
+
     bld.SAMBA_SUBSYSTEM('LIBREPLACE_HOSTCC',
         REPLACE_HOSTCC_SOURCE,
         use_hostcc=True,
         use_global_deps=False,
         cflags='-DSOCKET_WRAPPER_DISABLE=1 -DNSS_WRAPPER_DISABLE=1 -DUID_WRAPPER_DISABLE=1 -D_SAMBA_HOSTCC_',
-        group='compiler_libraries'
+        group='compiler_libraries',
+        deps = extra_libs
     )
 
     REPLACE_SOURCE = REPLACE_HOSTCC_SOURCE
@@ -451,9 +546,8 @@ def build(bld):
     if not bld.CONFIG_SET('HAVE_INET_ATON'):     REPLACE_SOURCE += ' inet_aton.c'
     if not bld.CONFIG_SET('HAVE_INET_NTOP'):     REPLACE_SOURCE += ' inet_ntop.c'
     if not bld.CONFIG_SET('HAVE_INET_PTON'):     REPLACE_SOURCE += ' inet_pton.c'
-
-    extra_libs = ''
-    if bld.CONFIG_SET('HAVE_LIBBSD'): extra_libs += ' bsd'
+    if not bld.CONFIG_SET('HAVE_GETXATTR') or bld.CONFIG_SET('XATTR_ADDITIONAL_OPTIONS'):
+                                                 REPLACE_SOURCE += ' xattr.c'
 
     bld.SAMBA_LIBRARY('replace',
                       source=REPLACE_SOURCE,
@@ -464,7 +558,7 @@ def build(bld):
                       # at the moment:
                       # hide_symbols=bld.BUILTIN_LIBRARY('replace'),
                       private_library=True,
-                      deps='crypt dl nsl socket rt' + extra_libs)
+                      deps='crypt dl nsl socket rt attr' + extra_libs)
 
     bld.SAMBA_SUBSYSTEM('replace-test',
                       source='''test/testsuite.c test/strptime.c
diff --git a/lib/replace/xattr.c b/lib/replace/xattr.c
new file mode 100644 (file)
index 0000000..8e1c989
--- /dev/null
@@ -0,0 +1,720 @@
+/* 
+   Unix SMB/CIFS implementation.
+   replacement routines for xattr implementations
+   Copyright (C) Jeremy Allison  1998-2005
+   Copyright (C) Timur Bakeyev        2005
+   Copyright (C) Bjoern Jacke    2006-2007
+   Copyright (C) Herb Lewis           2003
+   Copyright (C) Andrew Bartlett      2012
+
+     ** NOTE! The following LGPL license applies to the replace
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/dir.h"
+
+/******** Solaris EA helper function prototypes ********/
+#ifdef HAVE_ATTROPEN
+#define SOLARIS_ATTRMODE S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP
+static int solaris_write_xattr(int attrfd, const char *value, size_t size);
+static ssize_t solaris_read_xattr(int attrfd, void *value, size_t size);
+static ssize_t solaris_list_xattr(int attrdirfd, char *list, size_t size);
+static int solaris_unlinkat(int attrdirfd, const char *name);
+static int solaris_attropen(const char *path, const char *attrpath, int oflag, mode_t mode);
+static int solaris_openat(int fildes, const char *path, int oflag, mode_t mode);
+#endif
+
+/**************************************************************************
+ Wrappers for extented attribute calls. Based on the Linux package with
+ support for IRIX and (Net|Free)BSD also. Expand as other systems have them.
+****************************************************************************/
+
+ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t size)
+{
+#if defined(HAVE_GETXATTR)
+#ifndef XATTR_ADDITIONAL_OPTIONS
+       return getxattr(path, name, value, size);
+#else
+
+/* So that we do not recursivly call this function */
+#undef getxattr
+       int options = 0;
+       return getxattr(path, name, value, size, 0, options);
+#endif
+#elif defined(HAVE_GETEA)
+       return getea(path, name, value, size);
+#elif defined(HAVE_EXTATTR_GET_FILE)
+       char *s;
+       ssize_t retval;
+       int attrnamespace = (strncmp(name, "system", 6) == 0) ? 
+               EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
+       const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
+       /*
+        * The BSD implementation has a nasty habit of silently truncating
+        * the returned value to the size of the buffer, so we have to check
+        * that the buffer is large enough to fit the returned value.
+        */
+       if((retval=extattr_get_file(path, attrnamespace, attrname, NULL, 0)) >= 0) {
+               if(retval > size) {
+                       errno = ERANGE;
+                       return -1;
+               }
+               if((retval=extattr_get_file(path, attrnamespace, attrname, value, size)) >= 0)
+                       return retval;
+       }
+
+       return -1;
+#elif defined(HAVE_ATTR_GET)
+       int retval, flags = 0;
+       int valuelength = (int)size;
+       char *attrname = strchr(name,'.') + 1;
+
+       if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT;
+
+       retval = attr_get(path, attrname, (char *)value, &valuelength, flags);
+
+       return retval ? retval : valuelength;
+#elif defined(HAVE_ATTROPEN)
+       ssize_t ret = -1;
+       int attrfd = solaris_attropen(path, name, O_RDONLY, 0);
+       if (attrfd >= 0) {
+               ret = solaris_read_xattr(attrfd, value, size);
+               close(attrfd);
+       }
+       return ret;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
+{
+#if defined(HAVE_FGETXATTR)
+#ifndef XATTR_ADDITIONAL_OPTIONS
+       return fgetxattr(filedes, name, value, size);
+#else
+
+/* So that we do not recursivly call this function */
+#undef fgetxattr
+       int options = 0;
+       return fgetxattr(filedes, name, value, size, 0, options);
+#endif
+#elif defined(HAVE_FGETEA)
+       return fgetea(filedes, name, value, size);
+#elif defined(HAVE_EXTATTR_GET_FD)
+       char *s;
+       ssize_t retval;
+       int attrnamespace = (strncmp(name, "system", 6) == 0) ? 
+               EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
+       const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
+
+       if((retval=extattr_get_fd(filedes, attrnamespace, attrname, NULL, 0)) >= 0) {
+               if(retval > size) {
+                       errno = ERANGE;
+                       return -1;
+               }
+               if((retval=extattr_get_fd(filedes, attrnamespace, attrname, value, size)) >= 0)
+                       return retval;
+       }
+
+       return -1;
+#elif defined(HAVE_ATTR_GETF)
+       int retval, flags = 0;
+       int valuelength = (int)size;
+       char *attrname = strchr(name,'.') + 1;
+
+       if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT;
+
+       retval = attr_getf(filedes, attrname, (char *)value, &valuelength, flags);
+
+       return retval ? retval : valuelength;
+#elif defined(HAVE_ATTROPEN)
+       ssize_t ret = -1;
+       int attrfd = solaris_openat(filedes, name, O_RDONLY|O_XATTR, 0);
+       if (attrfd >= 0) {
+               ret = solaris_read_xattr(attrfd, value, size);
+               close(attrfd);
+       }
+       return ret;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+#if defined(HAVE_EXTATTR_LIST_FILE)
+
+#define EXTATTR_PREFIX(s)      (s), (sizeof((s))-1)
+
+static struct {
+        int space;
+       const char *name;
+       size_t len;
+} 
+extattr[] = {
+       { EXTATTR_NAMESPACE_SYSTEM, EXTATTR_PREFIX("system.") },
+        { EXTATTR_NAMESPACE_USER, EXTATTR_PREFIX("user.") },
+};
+
+typedef union {
+       const char *path;
+       int filedes;
+} extattr_arg;
+
+static ssize_t bsd_attr_list (int type, extattr_arg arg, char *list, size_t size)
+{
+       ssize_t list_size, total_size = 0;
+       int i, t, len;
+       char *buf;
+       /* Iterate through extattr(2) namespaces */
+       for(t = 0; t < ARRAY_SIZE(extattr); t++) {
+               switch(type) {
+#if defined(HAVE_EXTATTR_LIST_FILE)
+                       case 0:
+                               list_size = extattr_list_file(arg.path, extattr[t].space, list, size);
+                               break;
+#endif
+#if defined(HAVE_EXTATTR_LIST_LINK)
+                       case 1:
+                               list_size = extattr_list_link(arg.path, extattr[t].space, list, size);
+                               break;
+#endif
+#if defined(HAVE_EXTATTR_LIST_FD)
+                       case 2:
+                               list_size = extattr_list_fd(arg.filedes, extattr[t].space, list, size);
+                               break;
+#endif
+                       default:
+                               errno = ENOSYS;
+                               return -1;
+               }
+               /* Some error happend. Errno should be set by the previous call */
+               if(list_size < 0)
+                       return -1;
+               /* No attributes */
+               if(list_size == 0)
+                       continue;
+               /* XXX: Call with an empty buffer may be used to calculate
+                  necessary buffer size. Unfortunately, we can't say, how
+                  many attributes were returned, so here is the potential
+                  problem with the emulation.
+               */
+               if(list == NULL) {
+                       /* Take the worse case of one char attribute names - 
+                          two bytes per name plus one more for sanity.
+                       */
+                       total_size += list_size + (list_size/2 + 1)*extattr[t].len;
+                       continue;
+               }
+               /* Count necessary offset to fit namespace prefixes */
+               len = 0;
+               for(i = 0; i < list_size; i += list[i] + 1)
+                       len += extattr[t].len;
+
+               total_size += list_size + len;
+               /* Buffer is too small to fit the results */
+               if(total_size > size) {
+                       errno = ERANGE;
+                       return -1;
+               }
+               /* Shift results back, so we can prepend prefixes */
+               buf = (char *)memmove(list + len, list, list_size);
+
+               for(i = 0; i < list_size; i += len + 1) {
+                       len = buf[i];
+                       strncpy(list, extattr[t].name, extattr[t].len + 1);
+                       list += extattr[t].len;
+                       strncpy(list, buf + i + 1, len);
+                       list[len] = '\0';
+                       list += len + 1;
+               }
+               size -= total_size;
+       }
+       return total_size;
+}
+
+#endif
+
+#if defined(HAVE_ATTR_LIST) && (defined(HAVE_SYS_ATTRIBUTES_H) || defined(HAVE_ATTR_ATTRIBUTES_H))
+static char attr_buffer[ATTR_MAX_VALUELEN];
+
+static ssize_t irix_attr_list(const char *path, int filedes, char *list, size_t size, int flags)
+{
+       int retval = 0, index;
+       attrlist_cursor_t *cursor = 0;
+       int total_size = 0;
+       attrlist_t * al = (attrlist_t *)attr_buffer;
+       attrlist_ent_t *ae;
+       size_t ent_size, left = size;
+       char *bp = list;
+
+       while (true) {
+           if (filedes)
+               retval = attr_listf(filedes, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
+           else
+               retval = attr_list(path, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
+           if (retval) break;
+           for (index = 0; index < al->al_count; index++) {
+               ae = ATTR_ENTRY(attr_buffer, index);
+               ent_size = strlen(ae->a_name) + sizeof("user.");
+               if (left >= ent_size) {
+                   strncpy(bp, "user.", sizeof("user."));
+                   strncat(bp, ae->a_name, ent_size - sizeof("user."));
+                   bp += ent_size;
+                   left -= ent_size;
+               } else if (size) {
+                   errno = ERANGE;
+                   retval = -1;
+                   break;
+               }
+               total_size += ent_size;
+           }
+           if (al->al_more == 0) break;
+       }
+       if (retval == 0) {
+           flags |= ATTR_ROOT;
+           cursor = 0;
+           while (true) {
+               if (filedes)
+                   retval = attr_listf(filedes, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
+               else
+                   retval = attr_list(path, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
+               if (retval) break;
+               for (index = 0; index < al->al_count; index++) {
+                   ae = ATTR_ENTRY(attr_buffer, index);
+                   ent_size = strlen(ae->a_name) + sizeof("system.");
+                   if (left >= ent_size) {
+                       strncpy(bp, "system.", sizeof("system."));
+                       strncat(bp, ae->a_name, ent_size - sizeof("system."));
+                       bp += ent_size;
+                       left -= ent_size;
+                   } else if (size) {
+                       errno = ERANGE;
+                       retval = -1;
+                       break;
+                   }
+                   total_size += ent_size;
+               }
+               if (al->al_more == 0) break;
+           }
+       }
+       return (ssize_t)(retval ? retval : total_size);
+}
+
+#endif
+
+ssize_t rep_listxattr (const char *path, char *list, size_t size)
+{
+#if defined(HAVE_LISTXATTR)
+#ifndef XATTR_ADDITIONAL_OPTIONS
+       return listxattr(path, list, size);
+#else
+/* So that we do not recursivly call this function */
+#undef listxattr
+       int options = 0;
+       return listxattr(path, list, size, options);
+#endif
+#elif defined(HAVE_LISTEA)
+       return listea(path, list, size);
+#elif defined(HAVE_EXTATTR_LIST_FILE)
+       extattr_arg arg;
+       arg.path = path;
+       return bsd_attr_list(0, arg, list, size);
+#elif defined(HAVE_ATTR_LIST) && defined(HAVE_SYS_ATTRIBUTES_H)
+       return irix_attr_list(path, 0, list, size, 0);
+#elif defined(HAVE_ATTROPEN)
+       ssize_t ret = -1;
+       int attrdirfd = solaris_attropen(path, ".", O_RDONLY, 0);
+       if (attrdirfd >= 0) {
+               ret = solaris_list_xattr(attrdirfd, list, size);
+               close(attrdirfd);
+       }
+       return ret;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+ssize_t rep_flistxattr (int filedes, char *list, size_t size)
+{
+#if defined(HAVE_FLISTXATTR)
+#ifndef XATTR_ADDITIONAL_OPTIONS
+       return flistxattr(filedes, list, size);
+#else
+/* So that we do not recursivly call this function */
+#undef flistxattr
+       int options = 0;
+       return flistxattr(filedes, list, size, options);
+#endif
+#elif defined(HAVE_FLISTEA)
+       return flistea(filedes, list, size);
+#elif defined(HAVE_EXTATTR_LIST_FD)
+       extattr_arg arg;
+       arg.filedes = filedes;
+       return bsd_attr_list(2, arg, list, size);
+#elif defined(HAVE_ATTR_LISTF)
+       return irix_attr_list(NULL, filedes, list, size, 0);
+#elif defined(HAVE_ATTROPEN)
+       ssize_t ret = -1;
+       int attrdirfd = solaris_openat(filedes, ".", O_RDONLY|O_XATTR, 0);
+       if (attrdirfd >= 0) {
+               ret = solaris_list_xattr(attrdirfd, list, size);
+               close(attrdirfd);
+       }
+       return ret;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+int rep_removexattr (const char *path, const char *name)
+{
+#if defined(HAVE_REMOVEXATTR)
+#ifndef XATTR_ADDITIONAL_OPTIONS
+       return removexattr(path, name);
+#else
+/* So that we do not recursivly call this function */
+#undef removexattr
+       int options = 0;
+       return removexattr(path, name, options);
+#endif
+#elif defined(HAVE_REMOVEEA)
+       return removeea(path, name);
+#elif defined(HAVE_EXTATTR_DELETE_FILE)
+       char *s;
+       int attrnamespace = (strncmp(name, "system", 6) == 0) ? 
+               EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
+       const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
+
+       return extattr_delete_file(path, attrnamespace, attrname);
+#elif defined(HAVE_ATTR_REMOVE)
+       int flags = 0;
+       char *attrname = strchr(name,'.') + 1;
+
+       if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT;
+
+       return attr_remove(path, attrname, flags);
+#elif defined(HAVE_ATTROPEN)
+       int ret = -1;
+       int attrdirfd = solaris_attropen(path, ".", O_RDONLY, 0);
+       if (attrdirfd >= 0) {
+               ret = solaris_unlinkat(attrdirfd, name);
+               close(attrdirfd);
+       }
+       return ret;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+int rep_fremovexattr (int filedes, const char *name)
+{
+#if defined(HAVE_FREMOVEXATTR)
+#ifndef XATTR_ADDITIONAL_OPTIONS
+       return fremovexattr(filedes, name);
+#else
+/* So that we do not recursivly call this function */
+#undef fremovexattr
+       int options = 0;
+       return fremovexattr(filedes, name, options);
+#endif
+#elif defined(HAVE_FREMOVEEA)
+       return fremoveea(filedes, name);
+#elif defined(HAVE_EXTATTR_DELETE_FD)
+       char *s;
+       int attrnamespace = (strncmp(name, "system", 6) == 0) ? 
+               EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
+       const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
+
+       return extattr_delete_fd(filedes, attrnamespace, attrname);
+#elif defined(HAVE_ATTR_REMOVEF)
+       int flags = 0;
+       char *attrname = strchr(name,'.') + 1;
+
+       if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT;
+
+       return attr_removef(filedes, attrname, flags);
+#elif defined(HAVE_ATTROPEN)
+       int ret = -1;
+       int attrdirfd = solaris_openat(filedes, ".", O_RDONLY|O_XATTR, 0);
+       if (attrdirfd >= 0) {
+               ret = solaris_unlinkat(attrdirfd, name);
+               close(attrdirfd);
+       }
+       return ret;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+int rep_setxattr (const char *path, const char *name, const void *value, size_t size, int flags)
+{
+#if defined(HAVE_SETXATTR)
+#ifndef XATTR_ADDITIONAL_OPTIONS
+       return setxattr(path, name, value, size, flags);
+#else
+/* So that we do not recursivly call this function */
+#undef setxattr
+       int options = 0;
+       return setxattr(path, name, value, size, 0, options);
+#endif
+#elif defined(HAVE_SETEA)
+       return setea(path, name, value, size, flags);
+#elif defined(HAVE_EXTATTR_SET_FILE)
+       char *s;
+       int retval = 0;
+       int attrnamespace = (strncmp(name, "system", 6) == 0) ? 
+               EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
+       const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
+       if (flags) {
+               /* Check attribute existence */
+               retval = extattr_get_file(path, attrnamespace, attrname, NULL, 0);
+               if (retval < 0) {
+                       /* REPLACE attribute, that doesn't exist */
+                       if (flags & XATTR_REPLACE && errno == ENOATTR) {
+                               errno = ENOATTR;
+                               return -1;
+                       }
+                       /* Ignore other errors */
+               }
+               else {
+                       /* CREATE attribute, that already exists */
+                       if (flags & XATTR_CREATE) {
+                               errno = EEXIST;
+                               return -1;
+                       }
+               }
+       }
+       retval = extattr_set_file(path, attrnamespace, attrname, value, size);
+       return (retval < 0) ? -1 : 0;
+#elif defined(HAVE_ATTR_SET)
+       int myflags = 0;
+       char *attrname = strchr(name,'.') + 1;
+
+       if (strncmp(name, "system", 6) == 0) myflags |= ATTR_ROOT;
+       if (flags & XATTR_CREATE) myflags |= ATTR_CREATE;
+       if (flags & XATTR_REPLACE) myflags |= ATTR_REPLACE;
+
+       return attr_set(path, attrname, (const char *)value, size, myflags);
+#elif defined(HAVE_ATTROPEN)
+       int ret = -1;
+       int myflags = O_RDWR;
+       int attrfd;
+       if (flags & XATTR_CREATE) myflags |= O_EXCL;
+       if (!(flags & XATTR_REPLACE)) myflags |= O_CREAT;
+       attrfd = solaris_attropen(path, name, myflags, (mode_t) SOLARIS_ATTRMODE);
+       if (attrfd >= 0) {
+               ret = solaris_write_xattr(attrfd, value, size);
+               close(attrfd);
+       }
+       return ret;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags)
+{
+#if defined(HAVE_FSETXATTR)
+#ifndef XATTR_ADDITIONAL_OPTIONS
+       return fsetxattr(filedes, name, value, size, flags);
+#else
+/* So that we do not recursivly call this function */
+#undef fsetxattr
+       int options = 0;
+       return fsetxattr(filedes, name, value, size, 0, options);
+#endif
+#elif defined(HAVE_FSETEA)
+       return fsetea(filedes, name, value, size, flags);
+#elif defined(HAVE_EXTATTR_SET_FD)
+       char *s;
+       int retval = 0;
+       int attrnamespace = (strncmp(name, "system", 6) == 0) ? 
+               EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
+       const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
+       if (flags) {
+               /* Check attribute existence */
+               retval = extattr_get_fd(filedes, attrnamespace, attrname, NULL, 0);
+               if (retval < 0) {
+                       /* REPLACE attribute, that doesn't exist */
+                       if (flags & XATTR_REPLACE && errno == ENOATTR) {
+                               errno = ENOATTR;
+                               return -1;
+                       }
+                       /* Ignore other errors */
+               }
+               else {
+                       /* CREATE attribute, that already exists */
+                       if (flags & XATTR_CREATE) {
+                               errno = EEXIST;
+                               return -1;
+                       }
+               }
+       }
+       retval = extattr_set_fd(filedes, attrnamespace, attrname, value, size);
+       return (retval < 0) ? -1 : 0;
+#elif defined(HAVE_ATTR_SETF)
+       int myflags = 0;
+       char *attrname = strchr(name,'.') + 1;
+
+       if (strncmp(name, "system", 6) == 0) myflags |= ATTR_ROOT;
+       if (flags & XATTR_CREATE) myflags |= ATTR_CREATE;
+       if (flags & XATTR_REPLACE) myflags |= ATTR_REPLACE;
+
+       return attr_setf(filedes, attrname, (const char *)value, size, myflags);
+#elif defined(HAVE_ATTROPEN)
+       int ret = -1;
+       int myflags = O_RDWR | O_XATTR;
+       int attrfd;
+       if (flags & XATTR_CREATE) myflags |= O_EXCL;
+       if (!(flags & XATTR_REPLACE)) myflags |= O_CREAT;
+       attrfd = solaris_openat(filedes, name, myflags, (mode_t) SOLARIS_ATTRMODE);
+       if (attrfd >= 0) {
+               ret = solaris_write_xattr(attrfd, value, size);
+               close(attrfd);
+       }
+       return ret;
+#else
+       errno = ENOSYS;
+       return -1;
+#endif
+}
+
+/**************************************************************************
+ helper functions for Solaris' EA support
+****************************************************************************/
+#ifdef HAVE_ATTROPEN
+static ssize_t solaris_read_xattr(int attrfd, void *value, size_t size)
+{
+       struct stat sbuf;
+
+       if (fstat(attrfd, &sbuf) == -1) {
+               errno = ENOATTR;
+               return -1;
+       }
+
+       /* This is to return the current size of the named extended attribute */
+       if (size == 0) {
+               return sbuf.st_size;
+       }
+
+       /* check size and read xattr */
+       if (sbuf.st_size > size) {
+               errno = ERANGE;
+               return -1;
+       }
+
+       return read(attrfd, value, sbuf.st_size);
+}
+
+static ssize_t solaris_list_xattr(int attrdirfd, char *list, size_t size)
+{
+       ssize_t len = 0;
+       DIR *dirp;
+       struct dirent *de;
+       int newfd = dup(attrdirfd);
+       /* CAUTION: The originating file descriptor should not be
+                   used again following the call to fdopendir().
+                   For that reason we dup() the file descriptor
+                   here to make things more clear. */
+       dirp = fdopendir(newfd);
+
+       while ((de = readdir(dirp))) {
+               size_t listlen = strlen(de->d_name) + 1;
+               if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) {
+                       /* we don't want "." and ".." here: */
+                       continue;
+               }
+
+               if (size == 0) {
+                       /* return the current size of the list of extended attribute names*/
+                       len += listlen;
+               } else {
+                       /* check size and copy entrieÑ• + nul into list. */
+                       if ((len + listlen) > size) {
+                               errno = ERANGE;
+                               len = -1;
+                               break;
+                       } else {
+                               strlcpy(list + len, de->d_name, listlen);
+                               len += listlen;
+                       }
+               }
+       }
+
+       if (closedir(dirp) == -1) {
+               return -1;
+       }
+       return len;
+}
+
+static int solaris_unlinkat(int attrdirfd, const char *name)
+{
+       if (unlinkat(attrdirfd, name, 0) == -1) {
+               if (errno == ENOENT) {
+                       errno = ENOATTR;
+               }
+               return -1;
+       }
+       return 0;
+}
+
+static int solaris_attropen(const char *path, const char *attrpath, int oflag, mode_t mode)
+{
+       int filedes = attropen(path, attrpath, oflag, mode);
+       if (filedes == -1) {
+               if (errno == EINVAL) {
+                       errno = ENOTSUP;
+               } else {
+                       errno = ENOATTR;
+               }
+       }
+       return filedes;
+}
+
+static int solaris_openat(int fildes, const char *path, int oflag, mode_t mode)
+{
+       int filedes = openat(fildes, path, oflag, mode);
+       if (filedes == -1) {
+               if (errno == EINVAL) {
+                       errno = ENOTSUP;
+               } else {
+                       errno = ENOATTR;
+               }
+       }
+       return filedes;
+}
+
+static int solaris_write_xattr(int attrfd, const char *value, size_t size)
+{
+       if ((ftruncate(attrfd, 0) == 0) && (write(attrfd, value, size) == size)) {
+               return 0;
+       } else {
+               return -1;
+       }
+}
+#endif /*HAVE_ATTROPEN*/
+
+
index 62c6808825687c197b48cc4bbb1f258321207cfa..80196c6c77b58c395f5dde78e3d19f6d9de4c4a3 100644 (file)
@@ -27,7 +27,6 @@ void inittalloc(void);
 static PyObject *pytalloc_report_full(PyObject *self, PyObject *args)
 {
        PyObject *py_obj = Py_None;
-       PyTypeObject *type;
 
        if (!PyArg_ParseTuple(args, "|O", &py_obj))
                return NULL;
@@ -35,7 +34,6 @@ static PyObject *pytalloc_report_full(PyObject *self, PyObject *args)
        if (py_obj == Py_None) {
                talloc_report_full(NULL, stdout);
        } else {
-               type = (PyTypeObject*)PyObject_Type(py_obj);
                talloc_report_full(pytalloc_get_mem_ctx(py_obj), stdout);
        }
        return Py_None;
@@ -52,7 +50,6 @@ static PyObject *pytalloc_enable_null_tracking(PyObject *self)
 static PyObject *pytalloc_total_blocks(PyObject *self, PyObject *args)
 {
        PyObject *py_obj = Py_None;
-       PyTypeObject *type;
 
        if (!PyArg_ParseTuple(args, "|O", &py_obj))
                return NULL;
@@ -61,8 +58,6 @@ static PyObject *pytalloc_total_blocks(PyObject *self, PyObject *args)
                return PyLong_FromLong(talloc_total_blocks(NULL));
        }
 
-       type = (PyTypeObject*)PyObject_Type(py_obj);
-
        return PyLong_FromLong(talloc_total_blocks(pytalloc_get_mem_ctx(py_obj)));
 }
 
diff --git a/script/abi_checks.sh b/script/abi_checks.sh
deleted file mode 100755 (executable)
index 66c4e60..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/sh
-
-#
-# abi_checks.sh - check for possible abi changes
-#
-# Copyright (C) 2009 Michael Adam <obnox@samba.org>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 3 of the License, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, see <http://www.gnu.org/licenses/>.
-#
-
-#
-# USAGE: abi_checks.sh LIBNAME header1 [header2 ...]
-#
-# This script creates symbol and signature lists from the provided header
-# files with the aid of the mksyms.sh and mksigs.pl scripts (saved as
-# $LIBNAME.exports.check and $LIBNAME.sigatures.check). It then compares
-# the resulting files with the files $LIBNAME.exports and $LIBNME.signatures
-# which it expects to find in the current directory.
-#
-
-LANG=C; export LANG
-LC_ALL=C; export LC_ALL
-LC_COLLATE=C; export LC_COLLATE
-
-exit_status=0
-script=$0
-dir_name=$(dirname ${script})
-
-if test x"$1" = "x" ; then
-       echo "USAGE: ${script} libname header [header ...]"
-       exit 1
-fi
-
-libname="$1"
-shift
-
-if test x"$1" = "x" ; then
-       echo "USAGE: ${script} libname header [header ...]"
-       exit 1
-fi
-
-headers="$*"
-
-exports_file=${libname}.exports
-exports_file_check=${exports_file}.check
-signatures_file=${libname}.signatures
-signatures_file_check=${signatures_file}.check
-
-
-${dir_name}/mksyms.sh awk ${exports_file_check} ${headers} 2>&1 > /dev/null
-cat ${headers} | ${dir_name}/mksigs.pl | sort| uniq > ${signatures_file_check} 2> /dev/null
-
-diff -u ${exports_file} ${exports_file_check}
-if test "x$?" != "x0" ; then
-       echo "WARNING: possible ABI change detected in exports!"
-       let exit_status++
-else
-       echo "exports check: OK"
-fi
-
-diff -u ${signatures_file} ${signatures_file_check}
-if test "x$?" != "x0" ; then
-       echo "WARNING: possible ABI change detected in signatures!"
-       let exit_status++
-else
-       echo "signatures check: OK"
-fi
-
-exit $exit_status
diff --git a/script/abi_checks_gcc.sh b/script/abi_checks_gcc.sh
deleted file mode 100755 (executable)
index e3d3b04..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-make clean
-
-mkdir abi
-ABI_CHECKS="-aux-info abi/\$@.X"
-make ABI_CHECK="$ABI_CHECKS" CC="/usr/bin/gcc"
-
-for i in abi/*.X; do cat $i | grep 'talloc\.h'; done | sort | uniq | awk -F "extern " '{ print $2 }' | sort > abi/signatures
-
-cat > abi/exports << EOF
-{
-    global:
-EOF
-cat abi/signatures | awk -F '(' '{ print $1 }' | awk -F ' ' '{ print "           "$NF";" }' | tr -d '*' | sort >> abi/exports
-# need to manually add talloc free for backward ABI compat
-echo '           talloc_free;' >> abi/exports
-cat >> abi/exports << EOF
-
-    local: *;
-};
-EOF
-
-rm -fr abi/*.X
-
-diff -u talloc.signatures abi/signatures
-if [ "$?" != "0" ]; then
-    echo "WARNING: Possible ABI Change!!"
-fi
-
-diff -u talloc.exports abi/exports
-if [ "$?" != "0" ]; then
-    echo "WARNING: Export file may be outdated!!"
-fi
diff --git a/script/mksigs.pl b/script/mksigs.pl
deleted file mode 100755 (executable)
index dfe36bc..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-#!/usr/bin/perl
-
-# mksigs.pl - extract signatures from C headers
-#
-# Copyright (C) Michael Adam 2009
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 3 of the License, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, see <http://www.gnu.org/licenses/>.
-
-# USAGE:  cat $header_files | mksigs.pl > $signature_file
-#
-# The header files to parse are read from stdin.
-# The output is in a form as produced by gcc with the -aux-info switch
-# and printed to stdout.
-
-use strict;
-use warnings;
-
-my $in_comment = 0;
-my $in_doxygen = 0;
-my $extern_C_block = 0;
-
-while (my $LINE = <>) {
-       # find end of started multi-line-comment
-       if ($in_comment) {
-               if ($LINE =~ /^.*?\*\/(.*)$/) {
-                       $LINE = $1;
-                       $in_comment = 0;
-               } else {
-                       # whole line within comment
-                       next;
-               }
-       }
-
-       # find end of DOXYGEN section
-       if ($in_doxygen) {
-               if ($LINE =~ /^#\s*else(?:\s+.*)?$/) {
-                       $in_doxygen = 0;
-               }
-               next;
-       }
-
-       # strip C++-style comments
-       $LINE =~ s/^(.*?)\/\/.*$/$1/;
-
-       # strip in-line-comments:
-       while ($LINE =~ /\/\*.*?\*\//) {
-               $LINE =~ s/\/\*.*?\*\///;
-       }
-
-       # find starts of multi-line-comments
-       if ($LINE =~ /^(.*)\/\*/) {
-               $in_comment = 1;
-               $LINE = $1;
-       }
-
-       # skip empty lines
-       next if $LINE =~ /^\s*$/;
-
-       # remove leading spaces
-       $LINE =~ s/^\s*(.*)$/$1/;
-
-       # concatenate lines split with "\" (usually macro defines)
-       while ($LINE =~ /^(.*?)\s+\\$/) {
-               my $LINE2 = <>;
-               $LINE = $1;
-               $LINE2 =~ s/^\s*(.*)$/$1/;
-               $LINE .= " " . $LINE2;
-       }
-
-        # remove DOXYGEN sections
-       if ($LINE =~ /^#\s*ifdef\s+DOXYGEN(?:\s+.*)?$/) {
-               $in_doxygen = 1;
-                next;
-       }
-
-
-       # remove all preprocessor directives
-       next if ($LINE =~ /^#/);
-
-       if ($LINE =~ /^extern\s+"C"\s+\{/) {
-               $extern_C_block = 1;
-               next;
-       }
-
-       if (($LINE =~ /^[^\{]*\}/) and $extern_C_block) {
-               $extern_C_block = 0;
-               next;
-       }
-
-       $LINE =~ s/^extern\s//;
-
-       # concatenate braces stretched over multiple lines
-       # (from structs or enums)
-       my $REST = $LINE;
-       my $braces = 0;
-       while (($REST =~ /[\{\}]/) or ($braces)) {
-               while ($REST =~ /[\{\}]/) {
-                       # collect opening
-                       while ($REST =~ /^[^\{\}]*\{(.*)$/) {
-                               $braces++;
-                               $REST = $1;
-                       }
-
-                       # collect closing
-                       while ($REST =~ /^[^\{\}]*\}(.*)$/) {
-                               $braces--;
-                               $REST = $1;
-                       }
-               }
-
-               # concatenate if not balanced
-               if ($braces) {
-                       if (my $LINE2 = <>) {
-                               $LINE2 =~ s/^\s*(.*)$/$1/;
-                               chomp($LINE);
-                               $LINE .= " " . $LINE2;
-                               chomp $REST;
-                               $REST .= " " . $LINE2;
-                       } else {
-                               print "ERROR: unbalanced braces ($braces)\n";
-                               last;
-                       }
-               }
-       }
-
-       # concetenate function prototypes that stretch over multiple lines
-       $REST = $LINE;
-       my $parenthesis = 0;
-       while (($REST =~ /[\(\)]/) or ($parenthesis)) {
-               while ($REST =~ /[\(\)]/) {
-                       # collect opening
-                       while ($REST =~ /^[^\(\)]*\((.*)$/) {
-                               $parenthesis++;
-                               $REST = $1;
-                       }
-
-                       # collect closing
-                       while ($REST =~ /^[^\(\)]*\)(.*)$/) {
-                               $parenthesis--;
-                               $REST = $1;
-                       }
-               }
-
-               # concatenate if not balanced
-               if ($parenthesis) {
-                       if (my $LINE2 = <>) {
-                               $LINE2 =~ s/^\s*(.*)$/$1/;
-                               chomp($LINE);
-                               $LINE .= " " . $LINE2;
-                               chomp($REST);
-                               $REST .= " " . $LINE2;
-                       } else {
-                               print "ERROR: unbalanced parantheses ($parenthesis)\n";
-                               last;
-                       }
-               }
-       }
-
-       next if ($LINE =~ /^typedef\s/);
-       next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/);
-       next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/);
-       next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/);
-
-       # remove trailing spaces
-       $LINE =~ s/(.*?)\s*$/$1/;
-
-       $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\([^\)]*\)(\s*[;,])/$1$2/;
-       $LINE =~ s/^(.*\))\s*[a-zA-Z0-9_]+\s*;$/$1;/;
-
-       # remove parameter names - slightly too coarse probably
-       $LINE =~ s/([\s\(]\*?)[_0-9a-zA-Z]+\s*([,\)])/$1$2/g;
-
-       # remedy (void) from last line
-       $LINE =~ s/\(\)/(void)/g;
-
-       # normalize spaces
-       $LINE =~ s/\s*\)\s*/)/g;
-       $LINE =~ s/\s*\(\s*/ (/g;
-       $LINE =~ s/\s*,\s*/, /g;
-
-       # normalize unsigned
-       $LINE =~ s/([\s,\(])unsigned([,\)])/$1unsigned int$2/g;
-
-       # normalize bool
-       $LINE =~ s/(\b)bool(\b)/_Bool/g;
-
-       print $LINE . "\n";
-}
diff --git a/script/mksyms.awk b/script/mksyms.awk
deleted file mode 100644 (file)
index 83497a7..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# mksyms.awk
-#
-# Extract symbols to export from C-header files.
-# output in version-script format for linking shared libraries.
-#
-# Copyright (C) 2008 Micheal Adam <obnox@samba.org>
-#
-BEGIN {
-       inheader=0;
-       indoxygen=0;
-}
-
-END {
-}
-
-{
-       if (inheader) {
-               if (match($0,"[)][^()]*[;][ \t]*$")) {
-                       inheader = 0;
-               }
-               next;
-       }
-       if (indoxygen) {
-               if (match($0,"^#[ \t]*else[ \t]*.*$")) {
-                       indoxygen = 0;
-               }
-               next;
-       }
-}
-
-/^static/ || /^[ \t]*typedef/ || !/^[a-zA-Z\_\#]/ {
-       next;
-}
-
-/^extern[ \t]+[^()]+[;][ \t]*$/ {
-       gsub(/[^ \t]+[ \t]+/, "");
-       sub(/[;][ \t]*$/, "");
-       printf "           %s;\n", $0;
-       next;
-}
-
-/^#[ \t]*ifdef[ \t]*DOXYGEN[ \t]*.*$/ {
-       indoxygen=1;
-       next;
-}
-
-# look for function headers:
-{
-       gotstart = 0;
-       if ($0 ~ /^[A-Za-z_][A-Za-z0-9_]+/) {
-               gotstart = 1;
-       }
-       if(!gotstart) {
-               next;
-       }
-}
-
-/[_A-Za-z0-9]+[ \t]*[(].*[)][^()]*;[ \t]*$/ {
-       sub(/[(].*$/, "");
-       gsub(/[^ \t]+[ \t]+/, "");
-       gsub(/^[*]+/, "");
-       printf "           %s;\n",$0;
-       next;
-}
-
-/[_A-Za-z0-9]+[ \t]*[(]/ {
-       inheader=1;
-       sub(/[(].*$/, "");
-       gsub(/[^ \t]+[ \t]+/, "");
-       gsub(/^[*]/, "");
-       printf "           %s;\n",$0;
-       next;
-}
-
diff --git a/script/mksyms.sh b/script/mksyms.sh
deleted file mode 100755 (executable)
index 089344f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#! /bin/sh
-
-#
-# mksyms.sh
-#
-# Extract symbols to export from C-header files.
-# output in version-script format for linking shared libraries.
-#
-# This is the shell wrapper for the mksyms.awk core script.
-#
-# Copyright (C) 2008 Micheal Adam <obnox@samba.org>
-#
-
-LANG=C; export LANG
-LC_ALL=C; export LC_ALL
-LC_COLLATE=C; export LC_COLLATE
-
-if [ $# -lt 2 ]
-then
-  echo "Usage: $0 awk output_file header_files"
-  exit 1
-fi
-
-awk="$1"
-shift
-
-symsfile="$1"
-shift
-symsfile_tmp="$symsfile.$$.tmp~"
-
-proto_src="`echo $@ | tr ' ' '\n' | sort | uniq `"
-
-echo creating $symsfile
-
-mkdir -p `dirname $symsfile`
-
-#Write header
-cat > $symsfile_tmp << EOF
-# This file is autogenerated, please DO NOT EDIT
-{
-    global:
-EOF
-
-#loop on each header
-for i in $proto_src; do
-${awk} -f `dirname $0`/mksyms.awk $i | sort >> $symsfile_tmp
-done;
-
-#Write tail
-cat >> $symsfile_tmp << EOF
-
-    local: *;
-};
-EOF
-
-if cmp -s $symsfile $symsfile_tmp 2>/dev/null
-then
-  echo "$symsfile unchanged"
-  rm $symsfile_tmp
-else
-  mv $symsfile_tmp $symsfile
-fi
diff --git a/script/release-script.sh b/script/release-script.sh
deleted file mode 100755 (executable)
index 4b8aac7..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/bash
-
-LNAME=talloc
-LINCLUDE=talloc.h
-
-if [ "$1" = "" ]; then
-    echo "Please provide version string, eg: 1.2.0"
-    exit 1
-fi
-
-if [ ! -d "lib/${LNAME}" ]; then
-    echo "Run this script from the samba base directory."
-    exit 1
-fi
-
-curbranch=`git branch |grep "^*" | tr -d "* "`
-
-version=$1
-strver=`echo ${version} | tr "." "-"`
-
-# Checkout the release tag
-git branch -f ${LNAME}-release-script-${strver} ${LNAME}-${strver}
-if [ ! "$?" = "0" ];  then
-    echo "Unable to checkout ${LNAME}-${strver} release"
-    exit 1
-fi
-
-function cleanquit {
-    #Clean up
-    git checkout $curbranch
-    git branch -d ${LNAME}-release-script-${strver}
-    exit $1
-}
-
-# NOTE: use cleanquit after this point
-git checkout ${LNAME}-release-script-${strver}
-
-# Test configure agrees with us
-confver=`grep "^AC_INIT" lib/${LNAME}/configure.ac | tr -d "AC_INIT(${LNAME}, " | tr -d ")"`
-if [ ! "$confver" = "$version" ]; then
-    echo "Wrong version, requested release for ${version}, found ${confver}"
-    cleanquit 1
-fi
-
-# Check exports and signatures are up to date
-pushd lib/${LNAME}
-./script/abi_checks.sh ${LNAME} ${LINCLUDE}
-abicheck=$?
-popd
-if [ ! "$abicheck" = "0" ]; then
-    echo "ERROR: ABI Checks produced warnings!"
-    cleanquit 1
-fi
-
-git clean -f -x -d lib/${LNAME}
-git clean -f -x -d lib/replace
-
-# Now build tarball
-cp -a lib/${LNAME} ${LNAME}-${version}
-cp -a lib/replace ${LNAME}-${version}/libreplace
-pushd ${LNAME}-${version}
-./autogen.sh
-popd
-tar cvzf ${LNAME}-${version}.tar.gz ${LNAME}-${version}
-rm -fr ${LNAME}-${version}
-
-cleanquit 0
-
index 38e6f21854a643559a4cf653ce8f7125f0984651..3e33fc0fad5122e945dfbfb3017cd09834419208 100644 (file)
--- a/talloc.c
+++ b/talloc.c
@@ -71,6 +71,7 @@
 #define TALLOC_FLAG_LOOP 0x02
 #define TALLOC_FLAG_POOL 0x04          /* This is a talloc pool */
 #define TALLOC_FLAG_POOLMEM 0x08       /* This is allocated in a pool */
+
 #define TALLOC_MAGIC_REFERENCE ((const char *)1)
 
 /* by default we abort when given a bad pointer (such as when talloc_free() is called 
@@ -227,6 +228,17 @@ struct talloc_reference_handle {
        const char *location;
 };
 
+struct talloc_memlimit {
+       struct talloc_chunk *parent;
+       struct talloc_memlimit *upper;
+       size_t max_size;
+       size_t cur_size;
+};
+
+static bool talloc_memlimit_check(struct talloc_memlimit *limit, size_t size);
+static bool talloc_memlimit_update(struct talloc_memlimit *limit,
+                                  size_t old_size, size_t new_size);
+
 typedef int (*talloc_destructor_t)(void *);
 
 struct talloc_chunk {
@@ -238,6 +250,15 @@ struct talloc_chunk {
        size_t size;
        unsigned flags;
 
+       /*
+        * limit semantics:
+        * if 'limit' is set it means all *new* children of the context will
+        * be limited to a total aggregate size ox max_size for memory
+        * allocations.
+        * cur_size is used to kep track of the current use
+        */
+       struct talloc_memlimit *limit;
+
        /*
         * "pool" has dual use:
         *
@@ -437,49 +458,50 @@ _PUBLIC_ const char *talloc_parent_name(const void *ptr)
   memory footprint of each talloc chunk by those 16 bytes.
 */
 
-#define TALLOC_POOL_HDR_SIZE 16
+union talloc_pool_chunk {
+       /* This lets object_count nestle into 16-byte padding of talloc_chunk,
+        * on 32-bit platforms. */
+       struct tc_pool_hdr {
+               struct talloc_chunk c;
+               unsigned int object_count;
+       } hdr;
+       /* This makes it always 16 byte aligned. */
+       char pad[TC_ALIGN16(sizeof(struct tc_pool_hdr))];
+};
 
-#define TC_POOL_SPACE_LEFT(_pool_tc) \
-       PTR_DIFF(TC_HDR_SIZE + (_pool_tc)->size + (char *)(_pool_tc), \
-                (_pool_tc)->pool)
+static void *tc_pool_end(union talloc_pool_chunk *pool_tc)
+{
+       return (char *)pool_tc + TC_HDR_SIZE + pool_tc->hdr.c.size;
+}
 
-#define TC_POOL_FIRST_CHUNK(_pool_tc) \
-       ((void *)(TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE + (char *)(_pool_tc)))
+static size_t tc_pool_space_left(union talloc_pool_chunk *pool_tc)
+{
+       return (char *)tc_pool_end(pool_tc) - (char *)pool_tc->hdr.c.pool;
+}
 
-#define TC_POOLMEM_CHUNK_SIZE(_tc) \
-       TC_ALIGN16(TC_HDR_SIZE + (_tc)->size)
+static void *tc_pool_first_chunk(union talloc_pool_chunk *pool_tc)
+{
+       return pool_tc + 1;
+}
 
-#define TC_POOLMEM_NEXT_CHUNK(_tc) \
-       ((void *)(TC_POOLMEM_CHUNK_SIZE(tc) + (char*)(_tc)))
+/* If tc is inside a pool, this gives the next neighbour. */
+static void *tc_next_chunk(struct talloc_chunk *tc)
+{
+       return (char *)tc + TC_ALIGN16(TC_HDR_SIZE + tc->size);
+}
 
 /* Mark the whole remaining pool as not accessable */
-#define TC_INVALIDATE_FILL_POOL(_pool_tc) do { \
-       if (unlikely(talloc_fill.enabled)) { \
-               size_t _flen = TC_POOL_SPACE_LEFT(_pool_tc); \
-               char *_fptr = (char *)(_pool_tc)->pool; \
-               memset(_fptr, talloc_fill.fill_value, _flen); \
-       } \
-} while(0)
+static void tc_invalidate_pool(union talloc_pool_chunk *pool_tc)
+{
+       size_t flen = tc_pool_space_left(pool_tc);
+
+       if (unlikely(talloc_fill.enabled)) {
+               memset(pool_tc->hdr.c.pool, talloc_fill.fill_value, flen);
+       }
 
 #if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
-/* Mark the whole remaining pool as not accessable */
-#define TC_INVALIDATE_VALGRIND_POOL(_pool_tc) do { \
-       size_t _flen = TC_POOL_SPACE_LEFT(_pool_tc); \
-       char *_fptr = (char *)(_pool_tc)->pool; \
-       VALGRIND_MAKE_MEM_NOACCESS(_fptr, _flen); \
-} while(0)
-#else
-#define TC_INVALIDATE_VALGRIND_POOL(_pool_tc) do { } while (0)
+       VALGRIND_MAKE_MEM_NOACCESS(pool_tc->hdr.c.pool, flen);
 #endif
-
-#define TC_INVALIDATE_POOL(_pool_tc) do { \
-       TC_INVALIDATE_FILL_POOL(_pool_tc); \
-       TC_INVALIDATE_VALGRIND_POOL(_pool_tc); \
-} while (0)
-
-static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc)
-{
-       return (unsigned int *)((char *)tc + TC_HDR_SIZE);
 }
 
 /*
@@ -489,7 +511,7 @@ static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc)
 static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
                                              size_t size)
 {
-       struct talloc_chunk *pool_ctx = NULL;
+       union talloc_pool_chunk *pool_ctx = NULL;
        size_t space_left;
        struct talloc_chunk *result;
        size_t chunk_size;
@@ -499,17 +521,17 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
        }
 
        if (parent->flags & TALLOC_FLAG_POOL) {
-               pool_ctx = parent;
+               pool_ctx = (union talloc_pool_chunk *)parent;
        }
        else if (parent->flags & TALLOC_FLAG_POOLMEM) {
-               pool_ctx = (struct talloc_chunk *)parent->pool;
+               pool_ctx = (union talloc_pool_chunk *)parent->pool;
        }
 
        if (pool_ctx == NULL) {
                return NULL;
        }
 
-       space_left = TC_POOL_SPACE_LEFT(pool_ctx);
+       space_left = tc_pool_space_left(pool_ctx);
 
        /*
         * Align size to 16 bytes
@@ -520,18 +542,18 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
                return NULL;
        }
 
-       result = (struct talloc_chunk *)pool_ctx->pool;
+       result = (struct talloc_chunk *)pool_ctx->hdr.c.pool;
 
 #if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
        VALGRIND_MAKE_MEM_UNDEFINED(result, size);
 #endif
 
-       pool_ctx->pool = (void *)((char *)result + chunk_size);
+       pool_ctx->hdr.c.pool = (void *)((char *)result + chunk_size);
 
        result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM;
        result->pool = pool_ctx;
 
-       *talloc_pool_objectcount(pool_ctx) += 1;
+       pool_ctx->hdr.object_count++;
 
        return result;
 }
@@ -542,6 +564,7 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
 static inline void *__talloc(const void *context, size_t size)
 {
        struct talloc_chunk *tc = NULL;
+       struct talloc_memlimit *limit = NULL;
 
        if (unlikely(context == NULL)) {
                context = null_context;
@@ -552,8 +575,18 @@ static inline void *__talloc(const void *context, size_t size)
        }
 
        if (context != NULL) {
-               tc = talloc_alloc_pool(talloc_chunk_from_ptr(context),
-                                      TC_HDR_SIZE+size);
+               struct talloc_chunk *ptc = talloc_chunk_from_ptr(context);
+
+               if (ptc->limit != NULL) {
+                       limit = ptc->limit;
+               }
+
+               if (!talloc_memlimit_check(limit, (TC_HDR_SIZE+size))) {
+                       errno = ENOMEM;
+                       return NULL;
+               }
+
+               tc = talloc_alloc_pool(ptc, TC_HDR_SIZE+size);
        }
 
        if (tc == NULL) {
@@ -563,6 +596,15 @@ static inline void *__talloc(const void *context, size_t size)
                tc->pool  = NULL;
        }
 
+       if (limit != NULL) {
+               struct talloc_memlimit *l;
+
+               for (l = limit; l != NULL; l = l->upper) {
+                       l->cur_size += TC_HDR_SIZE+size;
+               }
+       }
+
+       tc->limit = limit;
        tc->size = size;
        tc->destructor = NULL;
        tc->child = NULL;
@@ -595,21 +637,27 @@ static inline void *__talloc(const void *context, size_t size)
 
 _PUBLIC_ void *talloc_pool(const void *context, size_t size)
 {
-       void *result = __talloc(context, size + TALLOC_POOL_HDR_SIZE);
-       struct talloc_chunk *tc;
+       union talloc_pool_chunk *pool_tc;
+       void *result = __talloc(context, sizeof(*pool_tc) - TC_HDR_SIZE + size);
 
        if (unlikely(result == NULL)) {
                return NULL;
        }
 
-       tc = talloc_chunk_from_ptr(result);
-
-       tc->flags |= TALLOC_FLAG_POOL;
-       tc->pool = TC_POOL_FIRST_CHUNK(tc);
+       pool_tc = (union talloc_pool_chunk *)talloc_chunk_from_ptr(result);
+       if (unlikely(pool_tc->hdr.c.flags & TALLOC_FLAG_POOLMEM)) {
+               /* We don't handle this correctly, so fail. */
+               talloc_log("talloc: cannot allocate pool off another pool %s\n",
+                          talloc_get_name(context));
+               talloc_free(result);
+               return NULL;
+       }
+       pool_tc->hdr.c.flags |= TALLOC_FLAG_POOL;
+       pool_tc->hdr.c.pool = tc_pool_first_chunk(pool_tc);
 
-       *talloc_pool_objectcount(tc) = 1;
+       pool_tc->hdr.object_count = 1;
 
-       TC_INVALIDATE_POOL(tc);
+       tc_invalidate_pool(pool_tc);
 
        return result;
 }
@@ -712,12 +760,11 @@ static void *_talloc_steal_internal(const void *new_ctx, const void *ptr);
 static inline void _talloc_free_poolmem(struct talloc_chunk *tc,
                                        const char *location)
 {
-       struct talloc_chunk *pool;
+       union talloc_pool_chunk *pool;
        void *next_tc;
-       unsigned int *pool_object_count;
 
-       pool = (struct talloc_chunk *)tc->pool;
-       next_tc = TC_POOLMEM_NEXT_CHUNK(tc);
+       pool = (union talloc_pool_chunk *)tc->pool;
+       next_tc = tc_next_chunk(tc);
 
        tc->flags |= TALLOC_FLAG_FREE;
 
@@ -729,16 +776,15 @@ static inline void _talloc_free_poolmem(struct talloc_chunk *tc,
 
        TC_INVALIDATE_FULL_CHUNK(tc);
 
-       pool_object_count = talloc_pool_objectcount(pool);
-
-       if (unlikely(*pool_object_count == 0)) {
+       if (unlikely(pool->hdr.object_count == 0)) {
                talloc_abort("Pool object count zero!");
                return;
        }
 
-       *pool_object_count -= 1;
+       pool->hdr.object_count--;
 
-       if (unlikely(*pool_object_count == 1 && !(pool->flags & TALLOC_FLAG_FREE))) {
+       if (unlikely(pool->hdr.object_count == 1
+                    && !(pool->hdr.c.flags & TALLOC_FLAG_FREE))) {
                /*
                 * if there is just one object left in the pool
                 * and pool->flags does not have TALLOC_FLAG_FREE,
@@ -746,25 +792,25 @@ static inline void _talloc_free_poolmem(struct talloc_chunk *tc,
                 * the rest is available for new objects
                 * again.
                 */
-               pool->pool = TC_POOL_FIRST_CHUNK(pool);
-               TC_INVALIDATE_POOL(pool);
-       } else if (unlikely(*pool_object_count == 0)) {
+               pool->hdr.c.pool = tc_pool_first_chunk(pool);
+               tc_invalidate_pool(pool);
+       } else if (unlikely(pool->hdr.object_count == 0)) {
                /*
                 * we mark the freed memory with where we called the free
                 * from. This means on a double free error we can report where
                 * the first free came from
                 */
-               pool->name = location;
+               pool->hdr.c.name = location;
 
-               TC_INVALIDATE_FULL_CHUNK(pool);
+               TC_INVALIDATE_FULL_CHUNK(&pool->hdr.c);
                free(pool);
-       } else if (pool->pool == next_tc) {
+       } else if (pool->hdr.c.pool == next_tc) {
                /*
                 * if pool->pool still points to end of
                 * 'tc' (which is stored in the 'next_tc' variable),
                 * we can reclaim the memory of 'tc'.
                 */
-               pool->pool = tc;
+               pool->hdr.c.pool = tc;
        }
 }
 
@@ -847,6 +893,29 @@ static inline int _talloc_free_internal(void *ptr, const char *location)
 
        tc->flags |= TALLOC_FLAG_FREE;
 
+       /*
+        * If we are part of a memory limited context hierarchy
+        * we need to subtract the memory used from the counters
+        */
+       if (tc->limit) {
+               struct talloc_memlimit *l;
+
+               for (l = tc->limit; l != NULL; l = l->upper) {
+                       if (l->cur_size >= tc->size+TC_HDR_SIZE) {
+                               l->cur_size -= tc->size+TC_HDR_SIZE;
+                       } else {
+                               talloc_abort("cur_size memlimit counter not correct!");
+                               return 0;
+                       }
+               }
+
+               if (tc->limit->parent == tc) {
+                       free(tc->limit);
+               }
+
+               tc->limit = NULL;
+       }
+
        /* we mark the freed memory with where we called the free
         * from. This means on a double free error we can report where
         * the first free came from 
@@ -854,18 +923,15 @@ static inline int _talloc_free_internal(void *ptr, const char *location)
        tc->name = location;
 
        if (tc->flags & TALLOC_FLAG_POOL) {
-               unsigned int *pool_object_count;
-
-               pool_object_count = talloc_pool_objectcount(tc);
+               union talloc_pool_chunk *pool = (union talloc_pool_chunk *)tc;
 
-               if (unlikely(*pool_object_count == 0)) {
+               if (unlikely(pool->hdr.object_count == 0)) {
                        talloc_abort("Pool object count zero!");
                        return 0;
                }
 
-               *pool_object_count -= 1;
-
-               if (unlikely(*pool_object_count == 0)) {
+               pool->hdr.object_count--;
+               if (unlikely(pool->hdr.object_count == 0)) {
                        TC_INVALIDATE_FULL_CHUNK(tc);
                        free(tc);
                }
@@ -878,6 +944,10 @@ static inline int _talloc_free_internal(void *ptr, const char *location)
        return 0;
 }
 
+static size_t _talloc_total_limit_size(const void *ptr,
+                                       struct talloc_memlimit *old_limit,
+                                       struct talloc_memlimit *new_limit);
+
 /* 
    move a lump of memory from one talloc context to another return the
    ptr on success, or NULL if it could not be transferred.
@@ -886,6 +956,7 @@ static inline int _talloc_free_internal(void *ptr, const char *location)
 static void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
 {
        struct talloc_chunk *tc, *new_tc;
+       size_t ctx_size = 0;
 
        if (unlikely(!ptr)) {
                return NULL;
@@ -897,6 +968,23 @@ static void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
 
        tc = talloc_chunk_from_ptr(ptr);
 
+       if (tc->limit != NULL) {
+
+               ctx_size = _talloc_total_limit_size(ptr, NULL, NULL);
+
+               if (!talloc_memlimit_update(tc->limit->upper, ctx_size, 0)) {
+                       talloc_abort("cur_size memlimit counter not correct!");
+                       errno = EINVAL;
+                       return NULL;
+               }
+
+               if (tc->limit->parent == tc) {
+                       tc->limit->upper = NULL;
+               } else {
+                       tc->limit = NULL;
+               }
+       }
+
        if (unlikely(new_ctx == NULL)) {
                if (tc->parent) {
                        _TLIST_REMOVE(tc->parent->child, tc);
@@ -907,7 +995,7 @@ static void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
                        if (tc->prev) tc->prev->next = tc->next;
                        if (tc->next) tc->next->prev = tc->prev;
                }
-               
+
                tc->parent = tc->next = tc->prev = NULL;
                return discard_const_p(void, ptr);
        }
@@ -933,6 +1021,19 @@ static void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
        if (new_tc->child) new_tc->child->parent = NULL;
        _TLIST_ADD(new_tc->child, tc);
 
+       if (tc->limit || new_tc->limit) {
+               ctx_size = _talloc_total_limit_size(ptr, tc->limit,
+                                                   new_tc->limit);
+       }
+
+       if (new_tc->limit) {
+               struct talloc_memlimit *l;
+
+               for (l = new_tc->limit; l != NULL; l = l->upper) {
+                       l->cur_size += ctx_size;
+               }
+       }
+
        return discard_const_p(void, ptr);
 }
 
@@ -1066,7 +1167,7 @@ _PUBLIC_ int talloc_unlink(const void *context, void *ptr)
        if (tc_c != talloc_parent_chunk(ptr)) {
                return -1;
        }
-       
+
        tc_p = talloc_chunk_from_ptr(ptr);
 
        if (tc_p->refs == NULL) {
@@ -1380,7 +1481,7 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
        struct talloc_chunk *tc;
        void *new_ptr;
        bool malloced = false;
-       struct talloc_chunk *pool_tc = NULL;
+       union talloc_pool_chunk *pool_tc = NULL;
 
        /* size zero is equivalent to free() */
        if (unlikely(size == 0)) {
@@ -1409,20 +1510,28 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
                return NULL;
        }
 
-       /* don't let anybody try to realloc a talloc_pool */
+       if (tc->limit && (size - tc->size > 0)) {
+               if (!talloc_memlimit_check(tc->limit, (size - tc->size))) {
+                       errno = ENOMEM;
+                       return NULL;
+               }
+       }
+
+       /* handle realloc inside a talloc_pool */
        if (unlikely(tc->flags & TALLOC_FLAG_POOLMEM)) {
-               pool_tc = (struct talloc_chunk *)tc->pool;
+               pool_tc = (union talloc_pool_chunk *)tc->pool;
        }
 
 #if (ALWAYS_REALLOC == 0)
        /* don't shrink if we have less than 1k to gain */
-       if (size < tc->size) {
+       if (size < tc->size && tc->limit == NULL) {
                if (pool_tc) {
-                       void *next_tc = TC_POOLMEM_NEXT_CHUNK(tc);
+                       void *next_tc = tc_next_chunk(tc);
                        TC_INVALIDATE_SHRINK_CHUNK(tc, size);
                        tc->size = size;
-                       if (next_tc == pool_tc->pool) {
-                               pool_tc->pool = TC_POOLMEM_NEXT_CHUNK(tc);
+                       if (next_tc == pool_tc->hdr.c.pool) {
+                               /* note: tc->size has changed, so this works */
+                               pool_tc->hdr.c.pool = tc_next_chunk(tc);
                        }
                        return ptr;
                } else if ((tc->size - size) < 1024) {
@@ -1455,7 +1564,7 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
 #if ALWAYS_REALLOC
        if (pool_tc) {
                new_ptr = talloc_alloc_pool(tc, size + TC_HDR_SIZE);
-               *talloc_pool_objectcount(pool_tc) -= 1;
+               pool_tc->hdr.object_count--;
 
                if (new_ptr == NULL) {
                        new_ptr = malloc(TC_HDR_SIZE+size);
@@ -1475,14 +1584,14 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
        }
 #else
        if (pool_tc) {
-               void *next_tc = TC_POOLMEM_NEXT_CHUNK(tc);
-               size_t old_chunk_size = TC_POOLMEM_CHUNK_SIZE(tc);
+               void *next_tc = tc_next_chunk(tc);
+               size_t old_chunk_size = TC_ALIGN16(TC_HDR_SIZE + tc->size);
                size_t new_chunk_size = TC_ALIGN16(TC_HDR_SIZE + size);
                size_t space_needed;
                size_t space_left;
-               unsigned int chunk_count = *talloc_pool_objectcount(pool_tc);
+               unsigned int chunk_count = pool_tc->hdr.object_count;
 
-               if (!(pool_tc->flags & TALLOC_FLAG_FREE)) {
+               if (!(pool_tc->hdr.c.flags & TALLOC_FLAG_FREE)) {
                        chunk_count -= 1;
                }
 
@@ -1491,27 +1600,15 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
                         * optimize for the case where 'tc' is the only
                         * chunk in the pool.
                         */
+                       char *start = tc_pool_first_chunk(pool_tc);
                        space_needed = new_chunk_size;
-                       space_left = pool_tc->size - TALLOC_POOL_HDR_SIZE;
+                       space_left = (char *)tc_pool_end(pool_tc) - start;
 
                        if (space_left >= space_needed) {
                                size_t old_used = TC_HDR_SIZE + tc->size;
                                size_t new_used = TC_HDR_SIZE + size;
-                               pool_tc->pool = TC_POOL_FIRST_CHUNK(pool_tc);
-#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
-                               /*
-                                * we need to prepare the memmove into
-                                * the unaccessable area.
-                                */
-                               {
-                                       size_t diff = PTR_DIFF(tc, pool_tc->pool);
-                                       size_t flen = MIN(diff, old_used);
-                                       char *fptr = (char *)pool_tc->pool;
-                                       VALGRIND_MAKE_MEM_UNDEFINED(fptr, flen);
-                               }
-#endif
-                               memmove(pool_tc->pool, tc, old_used);
-                               new_ptr = pool_tc->pool;
+                               new_ptr = start;
+                               memmove(new_ptr, tc, old_used);
 
                                tc = (struct talloc_chunk *)new_ptr;
                                TC_UNDEFINE_GROW_CHUNK(tc, size);
@@ -1521,11 +1618,11 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
                                 * because we want to invalidate the padding
                                 * too.
                                 */
-                               pool_tc->pool = new_used + (char *)new_ptr;
-                               TC_INVALIDATE_POOL(pool_tc);
+                               pool_tc->hdr.c.pool = new_used + (char *)new_ptr;
+                               tc_invalidate_pool(pool_tc);
 
                                /* now the aligned pointer */
-                               pool_tc->pool = new_chunk_size + (char *)new_ptr;
+                               pool_tc->hdr.c.pool = new_chunk_size + (char *)new_ptr;
                                goto got_new_ptr;
                        }
 
@@ -1535,23 +1632,38 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
                if (new_chunk_size == old_chunk_size) {
                        TC_UNDEFINE_GROW_CHUNK(tc, size);
                        tc->flags &= ~TALLOC_FLAG_FREE;
+                       if (!talloc_memlimit_update(tc->limit,
+                                                       tc->size, size)) {
+                               talloc_abort("cur_size memlimit counter not"
+                                            " correct!");
+                               errno = EINVAL;
+                               return NULL;
+                       }
+
                        tc->size = size;
                        return ptr;
                }
 
-               if (next_tc == pool_tc->pool) {
+               if (next_tc == pool_tc->hdr.c.pool) {
                        /*
                         * optimize for the case where 'tc' is the last
                         * chunk in the pool.
                         */
                        space_needed = new_chunk_size - old_chunk_size;
-                       space_left = TC_POOL_SPACE_LEFT(pool_tc);
+                       space_left = tc_pool_space_left(pool_tc);
 
                        if (space_left >= space_needed) {
                                TC_UNDEFINE_GROW_CHUNK(tc, size);
                                tc->flags &= ~TALLOC_FLAG_FREE;
+                               if (!talloc_memlimit_update(tc->limit,
+                                                       tc->size, size)) {
+                                       talloc_abort("cur_size memlimit "
+                                                    "counter not correct!");
+                                       errno = EINVAL;
+                                       return NULL;
+                               }
                                tc->size = size;
-                               pool_tc->pool = TC_POOLMEM_NEXT_CHUNK(tc);
+                               pool_tc->hdr.c.pool = tc_next_chunk(tc);
                                return ptr;
                        }
                }
@@ -1598,6 +1710,11 @@ got_new_ptr:
                tc->next->prev = tc;
        }
 
+       if (!talloc_memlimit_update(tc->limit, tc->size, size)) {
+               talloc_abort("cur_size memlimit counter not correct!");
+               errno = EINVAL;
+               return NULL;
+       }
        tc->size = size;
        _talloc_set_name_const(TC_PTR_FROM_CHUNK(tc), name);
 
@@ -1616,10 +1733,16 @@ _PUBLIC_ void *_talloc_move(const void *new_ctx, const void *_pptr)
        return ret;
 }
 
-/*
-  return the total size of a talloc pool (subtree)
-*/
-_PUBLIC_ size_t talloc_total_size(const void *ptr)
+enum talloc_mem_count_type {
+       TOTAL_MEM_SIZE,
+       TOTAL_MEM_BLOCKS,
+       TOTAL_MEM_LIMIT,
+};
+
+static size_t _talloc_total_mem_internal(const void *ptr,
+                                        enum talloc_mem_count_type type,
+                                        struct talloc_memlimit *old_limit,
+                                        struct talloc_memlimit *new_limit)
 {
        size_t total = 0;
        struct talloc_chunk *c, *tc;
@@ -1633,17 +1756,50 @@ _PUBLIC_ size_t talloc_total_size(const void *ptr)
 
        tc = talloc_chunk_from_ptr(ptr);
 
+       if (old_limit || new_limit) {
+               if (tc->limit && tc->limit->upper == old_limit) {
+                       tc->limit->upper = new_limit;
+               }
+       }
+
+       /* optimize in the memlimits case */
+       if (type == TOTAL_MEM_LIMIT &&
+           tc->limit != NULL &&
+           tc->limit != old_limit &&
+           tc->limit->parent == tc) {
+               return tc->limit->cur_size;
+       }
+
        if (tc->flags & TALLOC_FLAG_LOOP) {
                return 0;
        }
 
        tc->flags |= TALLOC_FLAG_LOOP;
 
-       if (likely(tc->name != TALLOC_MAGIC_REFERENCE)) {
-               total = tc->size;
+       if (old_limit || new_limit) {
+               if (old_limit == tc->limit) {
+                       tc->limit = new_limit;
+               }
        }
-       for (c=tc->child;c;c=c->next) {
-               total += talloc_total_size(TC_PTR_FROM_CHUNK(c));
+
+       switch (type) {
+       case TOTAL_MEM_SIZE:
+               if (likely(tc->name != TALLOC_MAGIC_REFERENCE)) {
+                       total = tc->size;
+               }
+               break;
+       case TOTAL_MEM_BLOCKS:
+               total++;
+               break;
+       case TOTAL_MEM_LIMIT:
+               if (likely(tc->name != TALLOC_MAGIC_REFERENCE)) {
+                       total = tc->size + TC_HDR_SIZE;
+               }
+               break;
+       }
+       for (c = tc->child; c; c = c->next) {
+               total += _talloc_total_mem_internal(TC_PTR_FROM_CHUNK(c), type,
+                                                   old_limit, new_limit);
        }
 
        tc->flags &= ~TALLOC_FLAG_LOOP;
@@ -1651,37 +1807,20 @@ _PUBLIC_ size_t talloc_total_size(const void *ptr)
        return total;
 }
 
+/*
+  return the total size of a talloc pool (subtree)
+*/
+_PUBLIC_ size_t talloc_total_size(const void *ptr)
+{
+       return _talloc_total_mem_internal(ptr, TOTAL_MEM_SIZE, NULL, NULL);
+}
+
 /*
   return the total number of blocks in a talloc pool (subtree)
 */
 _PUBLIC_ size_t talloc_total_blocks(const void *ptr)
 {
-       size_t total = 0;
-       struct talloc_chunk *c, *tc;
-
-       if (ptr == NULL) {
-               ptr = null_context;
-       }
-       if (ptr == NULL) {
-               return 0;
-       }
-
-       tc = talloc_chunk_from_ptr(ptr);
-
-       if (tc->flags & TALLOC_FLAG_LOOP) {
-               return 0;
-       }
-
-       tc->flags |= TALLOC_FLAG_LOOP;
-
-       total++;
-       for (c=tc->child;c;c=c->next) {
-               total += talloc_total_blocks(TC_PTR_FROM_CHUNK(c));
-       }
-
-       tc->flags &= ~TALLOC_FLAG_LOOP;
-
-       return total;
+       return _talloc_total_mem_internal(ptr, TOTAL_MEM_BLOCKS, NULL, NULL);
 }
 
 /*
@@ -1743,6 +1882,7 @@ _PUBLIC_ void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
 static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_depth, int is_ref, void *_f)
 {
        const char *name = talloc_get_name(ptr);
+       struct talloc_chunk *tc;
        FILE *f = (FILE *)_f;
 
        if (is_ref) {
@@ -1750,6 +1890,16 @@ static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_
                return;
        }
 
+       tc = talloc_chunk_from_ptr(ptr);
+       if (tc->limit && tc->limit->parent == tc) {
+               fprintf(f, "%*s%-30s is a memlimit context"
+                       " (max_size = %lu bytes, cur_size = %lu bytes)\n",
+                       depth*4, "",
+                       name,
+                       (unsigned long)tc->limit->max_size,
+                       (unsigned long)tc->limit->cur_size);
+       }
+
        if (depth == 0) {
                fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n", 
                        (max_depth < 0 ? "full " :""), name,
@@ -2019,7 +2169,7 @@ _PUBLIC_ char *talloc_strdup_append_buffer(char *s, const char *a)
 _PUBLIC_ char *talloc_strndup_append(char *s, const char *a, size_t n)
 {
        if (unlikely(!s)) {
-               return talloc_strdup(NULL, a);
+               return talloc_strndup(NULL, a, n);
        }
 
        if (unlikely(!a)) {
@@ -2038,7 +2188,7 @@ _PUBLIC_ char *talloc_strndup_append_buffer(char *s, const char *a, size_t n)
        size_t slen;
 
        if (unlikely(!s)) {
-               return talloc_strdup(NULL, a);
+               return talloc_strndup(NULL, a, n);
        }
 
        if (unlikely(!a)) {
@@ -2368,3 +2518,80 @@ _PUBLIC_ int talloc_is_parent(const void *context, const void *ptr)
 {
        return _talloc_is_parent(context, ptr, TALLOC_MAX_DEPTH);
 }
+
+/*
+  return the total size of memory used by this context and all children
+*/
+static size_t _talloc_total_limit_size(const void *ptr,
+                                       struct talloc_memlimit *old_limit,
+                                       struct talloc_memlimit *new_limit)
+{
+       return _talloc_total_mem_internal(ptr, TOTAL_MEM_LIMIT,
+                                         old_limit, new_limit);
+}
+
+static bool talloc_memlimit_check(struct talloc_memlimit *limit, size_t size)
+{
+       struct talloc_memlimit *l;
+
+       for (l = limit; l != NULL; l = l->upper) {
+               if (l->max_size != 0 &&
+                   ((l->max_size <= l->cur_size) ||
+                    (l->max_size - l->cur_size < TC_HDR_SIZE+size))) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+static bool talloc_memlimit_update(struct talloc_memlimit *limit,
+                                  size_t old_size, size_t new_size)
+{
+       struct talloc_memlimit *l;
+       ssize_t d;
+
+       if (old_size == 0) {
+               d = new_size + TC_HDR_SIZE;
+       } else {
+               d = new_size - old_size;
+       }
+       for (l = limit; l != NULL; l = l->upper) {
+               ssize_t new_cur_size = l->cur_size + d;
+               if (new_cur_size < 0) {
+                       return false;
+               }
+               l->cur_size = new_cur_size;
+       }
+
+       return true;
+}
+
+_PUBLIC_ int talloc_set_memlimit(const void *ctx, size_t max_size)
+{
+       struct talloc_chunk *tc = talloc_chunk_from_ptr(ctx);
+       struct talloc_memlimit *orig_limit;
+       struct talloc_memlimit *limit = NULL;
+
+       if (tc->limit && tc->limit->parent == tc) {
+               tc->limit->max_size = max_size;
+               return 0;
+       }
+       orig_limit = tc->limit;
+
+       limit = malloc(sizeof(struct talloc_memlimit));
+       if (limit == NULL) {
+               return 1;
+       }
+       limit->parent = tc;
+       limit->max_size = max_size;
+       limit->cur_size = _talloc_total_limit_size(ctx, tc->limit, limit);
+
+       if (orig_limit) {
+               limit->upper = orig_limit;
+       } else {
+               limit->upper = NULL;
+       }
+
+       return 0;
+}
index 96c7e2467c27b27dd23107f799603fa855434351..f3cbcd0e7c0566aacee3e8752d065cab2eb7e04f 100644 (file)
--- a/talloc.h
+++ b/talloc.h
@@ -1,16 +1,16 @@
 #ifndef _TALLOC_H_
 #define _TALLOC_H_
-/* 
+/*
    Unix SMB/CIFS implementation.
    Samba temporary memory allocation functions
 
    Copyright (C) Andrew Tridgell 2004-2005
    Copyright (C) Stefan Metzmacher 2006
-   
+
      ** NOTE! The following LGPL license applies to the talloc
      ** library. This does NOT imply that all of Samba is released
      ** under the LGPL
-   
+
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
@@ -194,6 +194,11 @@ void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
  * talloc_set_log_stderr() for more information on talloc logging
  * functions.
  *
+ * If <code>TALLOC_FREE_FILL</code> environment variable is set,
+ * the memory occupied by the context is filled with the value of this variable.
+ * The value should be a numeric representation of the character you want to
+ * use.
+ *
  * talloc_free() operates recursively on its children.
  *
  * @param[in]  ptr      The chunk to be freed.
@@ -822,6 +827,10 @@ void *talloc_find_parent_bytype(const void *ptr, #type);
  * recursively. If you use the child of the talloc pool as a parent for
  * grand-children, their memory is also taken from the talloc pool.
  *
+ * If there is not enough memory in the pool to allocate the new child,
+ * it will create a new talloc chunk as if the parent was a normal talloc
+ * context.
+ *
  * If you talloc_free() children of a talloc pool, the memory is not given
  * back to the system. Instead, free(3) is only called if the talloc_pool()
  * itself is released with talloc_free().
@@ -830,7 +839,8 @@ void *talloc_find_parent_bytype(const void *ptr, #type);
  * talloc pool to a talloc parent outside the pool, the whole pool memory is
  * not free(3)'ed until that moved chunk is also talloc_free()ed.
  *
- * @param[in]  context  The talloc context to hang the result off.
+ * @param[in]  context  The talloc context to hang the result off (must not
+ *                     be another pool).
  *
  * @param[in]  size     Size of the talloc pool.
  *
@@ -1290,28 +1300,64 @@ void *talloc_realloc_fn(const void *context, void *ptr, size_t size);
 char *talloc_strdup(const void *t, const char *p);
 
 /**
- * @brief Append a string to given string and duplicate the result.
+ * @brief Append a string to given string.
+ *
+ * The destination string is reallocated to take
+ * <code>strlen(s) + strlen(a) + 1</code> characters.
+ *
+ * This functions sets the name of the new pointer to the new
+ * string. This is equivalent to:
+ *
+ * @code
+ *      talloc_set_name_const(ptr, ptr)
+ * @endcode
+ *
+ * If <code>s == NULL</code> then new context is created.
  *
  * @param[in]  s        The destination to append to.
  *
  * @param[in]  a        The string you want to append.
  *
- * @return              The duplicated string, NULL on error.
+ * @return              The concatenated strings, NULL on error.
  *
  * @see talloc_strdup()
+ * @see talloc_strdup_append_buffer()
  */
 char *talloc_strdup_append(char *s, const char *a);
 
 /**
- * @brief Append a string to a given buffer and duplicate the result.
+ * @brief Append a string to a given buffer.
+ *
+ * This is a more efficient version of talloc_strdup_append(). It determines the
+ * length of the destination string by the size of the talloc context.
+ *
+ * Use this very carefully as it produces a different result than
+ * talloc_strdup_append() when a zero character is in the middle of the
+ * destination string.
+ *
+ * @code
+ *      char *str_a = talloc_strdup(NULL, "hello world");
+ *      char *str_b = talloc_strdup(NULL, "hello world");
+ *      str_a[5] = str_b[5] = '\0'
+ *
+ *      char *app = talloc_strdup_append(str_a, ", hello");
+ *      char *buf = talloc_strdup_append_buffer(str_b, ", hello");
+ *
+ *      printf("%s\n", app); // hello, hello (app = "hello, hello")
+ *      printf("%s\n", buf); // hello (buf = "hello\0world, hello")
+ * @endcode
+ *
+ * If <code>s == NULL</code> then new context is created.
  *
  * @param[in]  s        The destination buffer to append to.
  *
  * @param[in]  a        The string you want to append.
  *
- * @return              The duplicated string, NULL on error.
+ * @return              The concatenated strings, NULL on error.
  *
  * @see talloc_strdup()
+ * @see talloc_strdup_append()
+ * @see talloc_array_length()
  */
 char *talloc_strdup_append_buffer(char *s, const char *a);
 
@@ -1338,8 +1384,19 @@ char *talloc_strdup_append_buffer(char *s, const char *a);
 char *talloc_strndup(const void *t, const char *p, size_t n);
 
 /**
- * @brief Append at most n characters of a string to given string and duplicate
- *        the result.
+ * @brief Append at most n characters of a string to given string.
+ *
+ * The destination string is reallocated to take
+ * <code>strlen(s) + strnlen(a, n) + 1</code> characters.
+ *
+ * This functions sets the name of the new pointer to the new
+ * string. This is equivalent to:
+ *
+ * @code
+ *      talloc_set_name_const(ptr, ptr)
+ * @endcode
+ *
+ * If <code>s == NULL</code> then new context is created.
  *
  * @param[in]  s        The destination string to append to.
  *
@@ -1348,15 +1405,36 @@ char *talloc_strndup(const void *t, const char *p, size_t n);
  * @param[in]  n        The number of characters you want to append from the
  *                      string.
  *
- * @return              The duplicated string, NULL on error.
+ * @return              The concatenated strings, NULL on error.
  *
  * @see talloc_strndup()
+ * @see talloc_strndup_append_buffer()
  */
 char *talloc_strndup_append(char *s, const char *a, size_t n);
 
 /**
- * @brief Append at most n characters of a string to given buffer and duplicate
- *        the result.
+ * @brief Append at most n characters of a string to given buffer
+ *
+ * This is a more efficient version of talloc_strndup_append(). It determines
+ * the length of the destination string by the size of the talloc context.
+ *
+ * Use this very carefully as it produces a different result than
+ * talloc_strndup_append() when a zero character is in the middle of the
+ * destination string.
+ *
+ * @code
+ *      char *str_a = talloc_strdup(NULL, "hello world");
+ *      char *str_b = talloc_strdup(NULL, "hello world");
+ *      str_a[5] = str_b[5] = '\0'
+ *
+ *      char *app = talloc_strndup_append(str_a, ", hello", 7);
+ *      char *buf = talloc_strndup_append_buffer(str_b, ", hello", 7);
+ *
+ *      printf("%s\n", app); // hello, hello (app = "hello, hello")
+ *      printf("%s\n", buf); // hello (buf = "hello\0world, hello")
+ * @endcode
+ *
+ * If <code>s == NULL</code> then new context is created.
  *
  * @param[in]  s        The destination buffer to append to.
  *
@@ -1365,9 +1443,11 @@ char *talloc_strndup_append(char *s, const char *a, size_t n);
  * @param[in]  n        The number of characters you want to append from the
  *                      string.
  *
- * @return              The duplicated string, NULL on error.
+ * @return              The concatenated strings, NULL on error.
  *
  * @see talloc_strndup()
+ * @see talloc_strndup_append()
+ * @see talloc_array_length()
  */
 char *talloc_strndup_append_buffer(char *s, const char *a, size_t n);
 
@@ -1462,6 +1542,8 @@ char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3)
  *      talloc_set_name_const(ptr, ptr)
  * @endcode
  *
+ * If <code>s == NULL</code> then new context is created.
+ *
  * @param[in]  s        The string to append to.
  *
  * @param[in]  fmt      The format string.
@@ -1475,6 +1557,27 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3
 /**
  * @brief Append a formatted string to another string.
  *
+ * This is a more efficient version of talloc_asprintf_append(). It determines
+ * the length of the destination string by the size of the talloc context.
+ *
+ * Use this very carefully as it produces a different result than
+ * talloc_asprintf_append() when a zero character is in the middle of the
+ * destination string.
+ *
+ * @code
+ *      char *str_a = talloc_strdup(NULL, "hello world");
+ *      char *str_b = talloc_strdup(NULL, "hello world");
+ *      str_a[5] = str_b[5] = '\0'
+ *
+ *      char *app = talloc_asprintf_append(str_a, "%s", ", hello");
+ *      char *buf = talloc_strdup_append_buffer(str_b, "%s", ", hello");
+ *
+ *      printf("%s\n", app); // hello, hello (app = "hello, hello")
+ *      printf("%s\n", buf); // hello (buf = "hello\0world, hello")
+ * @endcode
+ *
+ * If <code>s == NULL</code> then new context is created.
+ *
  * @param[in]  s        The string to append to
  *
  * @param[in]  fmt      The format string.
@@ -1482,6 +1585,9 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3
  * @param[in]  ...      The parameters used to fill fmt.
  *
  * @return              The formatted string, NULL on error.
+ *
+ * @see talloc_asprintf()
+ * @see talloc_asprintf_append()
  */
 char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
 
@@ -1685,12 +1791,78 @@ void talloc_enable_leak_report(void);
  */
 void talloc_enable_leak_report_full(void);
 
-/* @} ******************************************************************/
-
+/**
+ * @brief Set a custom "abort" function that is called on serious error.
+ *
+ * The default "abort" function is <code>abort()</code>.
+ *
+ * The "abort" function is called when:
+ *
+ * <ul>
+ *  <li>talloc_get_type_abort() fails</li>
+ *  <li>the provided pointer is not a valid talloc context</li>
+ *  <li>when the context meta data are invalid</li>
+ *  <li>when access after free is detected</li>
+ * </ul>
+ *
+ * Example:
+ *
+ * @code
+ * void my_abort(const char *reason)
+ * {
+ *      fprintf(stderr, "talloc abort: %s\n", reason);
+ *      abort();
+ * }
+ *
+ *      talloc_set_abort_fn(my_abort);
+ * @endcode
+ *
+ * @param[in]  abort_fn      The new "abort" function.
+ *
+ * @see talloc_set_log_fn()
+ * @see talloc_get_type()
+ */
 void talloc_set_abort_fn(void (*abort_fn)(const char *reason));
+
+/**
+ * @brief Set a logging function.
+ *
+ * @param[in]  log_fn      The logging function.
+ *
+ * @see talloc_set_log_stderr()
+ * @see talloc_set_abort_fn()
+ */
 void talloc_set_log_fn(void (*log_fn)(const char *message));
+
+/**
+ * @brief Set stderr as the output for logs.
+ *
+ * @see talloc_set_log_fn()
+ * @see talloc_set_abort_fn()
+ */
 void talloc_set_log_stderr(void);
 
+/**
+ * @brief Set a max memory limit for the current context hierarchy
+ *       This affects all children of this context and constrain any
+ *       allocation in the hierarchy to never exceed the limit set.
+ *       The limit can be removed by setting 0 (unlimited) as the
+ *       max_size by calling the funciton again on the sam context.
+ *       Memory limits can also be nested, meaning a hild can have
+ *       a stricter memory limit than a parent.
+ *       Memory limits are enforced only at memory allocation time.
+ *       Stealing a context into a 'limited' hierarchy properly
+ *       updates memory usage but does *not* cause failure if the
+ *       move causes the new parent to exceed its limits. However
+ *       any further allocation on that hierarchy will then fail.
+ *
+ * @param[in]  ctx             The talloc context to set the limit on
+ * @param[in]  max_size        The (new) max_size
+ */
+int talloc_set_memlimit(const void *ctx, size_t max_size);
+
+/* @} ******************************************************************/
+
 #if TALLOC_DEPRECATED
 #define talloc_zero_p(ctx, type) talloc_zero(ctx, type)
 #define talloc_p(ctx, type) talloc(ctx, type)
index 71917038be9f01ee466987052b44ac63fca1f192..d456cbb0c23a80e25bd0558cfeed02fc828a6f79 100644 (file)
@@ -848,7 +848,7 @@ static bool test_speed(void)
                        p1 = talloc_size(ctx, loop % 100);
                        p2 = talloc_strdup(p1, "foo bar");
                        p3 = talloc_size(p1, 300);
-                       talloc_free_children(ctx);
+                       talloc_free(p1);
                }
                count += 3 * loop;
        } while (timeval_elapsed(&tv) < 5.0);
@@ -1355,6 +1355,175 @@ static bool test_free_children(void)
        return true;
 }
 
+static bool test_memlimit(void)
+{
+       void *root;
+       char *l1, *l2, *l3, *l4, *l5, *t;
+
+       printf("test: memlimit\n# MEMORY LIMITS\n");
+
+       printf("==== talloc_new(NULL)\n");
+       root = talloc_new(NULL);
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_size(root, 2048)\n");
+       l1 = talloc_size(root, 2048);
+       torture_assert("memlimit", l1 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_free(l1)\n");
+       talloc_free(l1);
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(root, level 1)\n");
+       l1 = talloc_strdup(root, "level 1");
+       torture_assert("memlimit", l1 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_set_memlimit(l1, 2048)\n");
+       torture_assert("memlimit", talloc_set_memlimit(l1, 2048) == 0,
+               "failed: setting memlimit should never fail\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_size(root, 2048)\n");
+       l2 = talloc_size(l1, 2048);
+       torture_assert("memlimit", l2 == NULL,
+               "failed: alloc should fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(l1, level 2)\n");
+       l2 = talloc_strdup(l1, "level 2");
+       torture_assert("memlimit", l2 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_free(l2)\n");
+       talloc_free(l2);
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_size(NULL, 2048)\n");
+       l2 = talloc_size(NULL, 2048);
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_steal(l1, l2)\n");
+       talloc_steal(l1, l2);
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(l2, level 3)\n");
+       l3 = talloc_strdup(l2, "level 3");
+       torture_assert("memlimit", l3 == NULL,
+               "failed: alloc should fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_free(l2)\n");
+       talloc_free(l2);
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(NULL, level 2)\n");
+       l2 = talloc_strdup(NULL, "level 2");
+       talloc_steal(l1, l2);
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(l2, level 3)\n");
+       l3 = talloc_strdup(l2, "level 3");
+       torture_assert("memlimit", l3 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_set_memlimit(l3, 1024)\n");
+       torture_assert("memlimit", talloc_set_memlimit(l3, 1024) == 0,
+               "failed: setting memlimit should never fail\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(l3, level 4)\n");
+       l4 = talloc_strdup(l3, "level 4");
+       torture_assert("memlimit", l4 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_set_memlimit(l4, 512)\n");
+       torture_assert("memlimit", talloc_set_memlimit(l4, 512) == 0,
+               "failed: setting memlimit should never fail\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(l4, level 5)\n");
+       l5 = talloc_strdup(l4, "level 5");
+       torture_assert("memlimit", l5 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_realloc(NULL, l5, char, 600)\n");
+       t = talloc_realloc(NULL, l5, char, 600);
+       torture_assert("memlimit", t == NULL,
+               "failed: alloc should fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_realloc(NULL, l5, char, 5)\n");
+       l5 = talloc_realloc(NULL, l5, char, 5);
+       torture_assert("memlimit", l5 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(l3, level 4)\n");
+       l4 = talloc_strdup(l3, "level 4");
+       torture_assert("memlimit", l4 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_set_memlimit(l4, 512)\n");
+       torture_assert("memlimit", talloc_set_memlimit(l4, 512) == 0,
+               "failed: setting memlimit should never fail\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_strdup(l4, level 5)\n");
+       l5 = talloc_strdup(l4, "level 5");
+       torture_assert("memlimit", l5 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+
+       printf("==== Make new temp context and steal l5\n");
+       t = talloc_new(root);
+       talloc_steal(t, l5);
+
+       talloc_report_full(root, stdout);
+
+       printf("==== talloc_size(t, 2048)\n");
+       l1 = talloc_size(t, 2048);
+       torture_assert("memlimit", l1 != NULL,
+               "failed: alloc should not fail due to memory limit\n");
+
+       talloc_report_full(root, stdout);
+       talloc_free(root);
+
+       printf("success: memlimit\n");
+
+       return true;
+}
 
 static void test_reset(void)
 {
@@ -1416,6 +1585,9 @@ bool torture_local_talloc(struct torture_context *tctx)
        ret &= test_rusty();
        test_reset();
        ret &= test_free_children();
+       test_reset();
+       ret &= test_memlimit();
+
 
        if (ret) {
                test_reset();
diff --git a/wscript b/wscript
index 447406bf6e7a4be320f32c9a2f5d5b4e2db01fe5..8d3246b26bb937cffba24c944719fd13777e4e5b 100644 (file)
--- a/wscript
+++ b/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'talloc'
-VERSION = '2.0.7'
+VERSION = '2.0.8'
 
 
 blddir = 'bin'