glibc/sunrpc/rpc_main.c
Ulrich Drepper 11bf311edc [BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483, BZ #3493, BZ #3514, BZ #3515, BZ #3664, BZ #3673, BZ #3674]
2007-01-11  Jakub Jelinek  <jakub@redhat.com>
	* sysdeps/i386/soft-fp/sfp-machine.h: Remove.
	* sysdeps/x86_64/soft-fp/sfp-machine.h: Likewise.
2007-01-10  Ulrich Drepper  <drepper@redhat.com>
	* io/fts.c: Make sure fts_cur is always valid after return from
	fts_read.
	Patch by Miloslav Trmac <mitr@redhat.com>.
2006-10-27  Richard Sandiford  <richard@codesourcery.com>
	* elf/elf.h (R_MIPS_GLOB_DAT): Define.
	(R_MIPS_NUM): Bump by 1.
2007-01-03  Jakub Jelinek  <jakub@redhat.com>
	* posix/execvp.c: Include alloca.h.
	(allocate_scripts_argv): Renamed to...
	(scripts_argv): ... this.  Don't allocate buffer here nor count
	arguments.
	(execvp): Use alloca if possible.
	* posix/Makefile: Add rules to build and run tst-vfork3 test.
	* posix/tst-vfork3.c: New test.
	* stdlib/Makefile (tst-strtod3-ENV): Define.
2007-01-02  Ulrich Drepper  <drepper@redhat.com>
	* posix/getconf.c: Update copyright year.
	* nss/getent.c: Likewise.
	* iconv/iconvconfig.c: Likewise.
	* iconv/iconv_prog.c: Likewise.
	* elf/ldconfig.c: Likewise.
	* catgets/gencat.c: Likewise.
	* csu/version.c: Likewise.
	* elf/ldd.bash.in: Likewise.
	* elf/sprof.c (print_version): Likewise.
	* locale/programs/locale.c: Likewise.
	* locale/programs/localedef.c: Likewise.
	* nscd/nscd.c (print_version): Likewise.
	* debug/xtrace.sh: Likewise.
	* malloc/memusage.sh: Likewise.
	* malloc/mtrace.pl: Likewise.
	* debug/catchsegv.sh: Likewise.
2006-12-24  Ulrich Drepper  <drepper@redhat.com>
	* malloc/malloc.c (sYSMALLOc): Remove some unnecessary alignment
	attempts.
2006-12-23  Ulrich Drepper  <drepper@redhat.com>
	* posix/wordexp.c: Remove some unnecessary tests.
2006-12-20  SUGIOKA Toshinobu  <sugioka@itonet.co.jp>

	* sysdeps/unix/sysv/linux/sh/bits/shm.h: New file.

	* nss/getXXbyYY_r.c: Include atomic.h.
	(INTERNAL (REENTRANT_NAME)): Write startp after start_fct,
	add atomic_write_barrier () in between.

2006-11-28  Jakub Jelinek  <jakub@redhat.com>
	* elf/dl-support.c: Include dl-procinfo.h.
	* sysdeps/powerpc/dl-procinfo.h (PPC_PLATFORM_POWER4,
	PPC_PLATFORM_PPC970, PPC_PLATFORM_POWER5, PPC_PLATFORM_POWER5_PLUS,
	PPC_PLATFORM_POWER6, PPC_PLATFORM_CELL_BE, PPC_PLATFORM_POWER6X):
	Define.
	(_dl_string_platform): Use PPC_PLATFORM_* macros instead of
	hardcoded constants.
	* sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_platform): Use
	PPC_PLATFORM_* macros for array designators.
2006-11-11  Steven Munroe  <sjmunroe@us.ibm.com>
	* sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Add 3 new cap
	names to the beginning.
	(_dl_powerpc_platforms): Add "power6x".
	* sysdeps/powerpc/dl-procinfo.h (_DL_HWCAP_FIRST): Decrease.
	(HWCAP_IMPORTANT): Add PPC_FEATURE_HAS_DFP.
	(_DL_PLATFORMS_COUNT): Increase.
	(_dl_string_platform): Handle power6x case.
	* sysdeps/powerpc/sysdep.h (PPC_FEATURE_PA6T, PPC_FEATURE_HAS_DFP,
	PPC_FEATURE_POWER6_EXT): Define.
	(PPC_FEATURE_POWER5, PPC_FEATURE_POWER5_PLUS): Correct Comment.
	[-2^31 .. 2^31) range.
	* sysdeps/unix/sysv/linux/bits/statvfs.h: Define ST_RELATIME.
	* sysdeps/unix/sysv/linux/internal_statvfs.c (__statvfs_getflags):
	Handle relatime mount option.

2006-12-13  Jakub Jelinek  <jakub@redhat.com>
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S: Include
	kernel-features.h.

2006-12-11  Ulrich Drepper  <drepper@redhat.com>

	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Parse thousand
	separators also if no non-zero digits found.
	* stdlib/Makefile (tests): Add tst-strtod3.
	[BZ #3664]
	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Fix test to recognize
	empty parsed strings.
	* stdlib/Makefile (tests): Add tst-strtod2.
	* stdlib/tst-strtod2.c: New file.

	[BZ #3673]
	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Fix exp_limit
	computation.
	* stdlib/Makefile (tests): Add tst-atof2.
	* stdlib/tst-atof2.c: New file.

	[BZ #3674]
	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Adjust exponent value
	correctly if removing trailing zero of hex-float.
	* stdlib/Makefile (tests): Add tst-atof1.
	* stdlib/tst-atof1.c: New file.

	* misc/mntent_r.c (__hasmntopt): Check p[optlen] even when p == rest.
	Start searching for next comma at p rather than rest.
	* misc/Makefile (tests): Add tst-mntent2.
	* misc/tst-mntent2.c: New test.

2006-12-08  Ulrich Drepper  <drepper@redhat.com>
	* malloc/memusage.c: Handle realloc with new size of zero and
	non-NULL pointer correctly.
	(me): Really write first record twice.
	(struct entry): Make format bi-arch safe.
	(dest): Write out more realloc statistics.
	* malloc/memusagestat.c (struct entry): Make format bi-arch safe.
2006-12-05  Jakub Jelinek  <jakub@redhat.com>
	* nis/nis_subr.c (nis_getnames): Revert last change.
2006-12-03  Kaz Kojima  <kkojima@rr.iij4u.or.jp>
	* sysdeps/unix/sysv/linux/sh/sys/io.h: Removed.
2006-11-30  H.J. Lu  <hongjiu.lu@intel.com>
	* sysdeps/i386/i686/memcmp.S: Use jump table as the base of
	jump table entries.

2006-11-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* sysdeps/unix/sysv/linux/i386/clone.S: Provide CFI for the outermost
	`clone' function to ensure proper unwinding stop of gdb.
	* sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.

2006-12-01  Ulrich Drepper  <drepper@redhat.com>

	* nscd/nscd.init: Remove obsolete and commented-out -S option
	handling.

2006-11-23  Jakub Jelinek  <jakub@redhat.com>

	[BZ #3514]
	* manual/string.texi (strncmp): Fix pastos from wcscmp description.

	[BZ #3515]
	* manual/string.texi (strtok): Remove duplicate paragraph.

2006-12-01  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* sysdeps/unix/sysv/linux/x86_64/sigaction.c: Fix compatibility with
	libgcc not supporting `rflags' unwinding (register # >= 17).

2006-11-30  Jakub Jelinek  <jakub@redhat.com>

	* sunrpc/svc_run.c (svc_run): Set my_pollfd to new_pollfd if realloc
	succeeded.

2006-11-29  Daniel Jacobowitz  <dan@codesourcery.com>
	    Jakub Jelinek  <jakub@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* sysdeps/unix/sysv/linux/x86_64/sigaction.c (restore_rt): Add correct
	unwind information.
	* sysdeps/unix/sysv/linux/x86_64/Makefile: Provide symbols for
	'restore_rt' even in the 'signal' directory.
	* sysdeps/unix/sysv/linux/x86_64/ucontext_i.sym: Extend the regs list.
	malloc crashed.  Don't allocate memory unnecessarily in each
	loop.
2006-10-21  Jakub Jelinek  <jakub@redhat.com>
	* resolv/mapv4v6addr.h (map_v4v6_address): Fix last change.
2006-11-20  Ulrich Drepper  <drepper@redhat.com>
	* resolv/mapv4v6addr.h (map_v4v6_address): Optimize a bit.
2006-11-18  Bruno Haible  <bruno@clisp.org>
	* sysdeps/unix/sysv/linux/i386/getgroups.c (__getgroups): Invoke
	__sysconf only after having tried to call getgroups32.
2006-11-19  Ulrich Drepper  <drepper@redhat.com>
	* nss/nss_files/files-hosts.c (LINE_PARSER): Support IPv6-style
	addresses for IPv4 queries if they can be mapped.
2006-11-16  Jakub Jelinek  <jakub@redhat.com>
	* sysdeps/x86_64/fpu/s_copysignf.S (__copysignf): Switch to .text.
	* sysdeps/x86_64/fpu/s_copysign.S (__copysign): Likewise.
	(signmask): Add .size directive.
	(othermask): Add .type directive.
2006-11-14  Ulrich Drepper  <drepper@redhat.com>
	* po/nl.po: Update from translation team.
	* timezone/zdump.c: Redo fix for BZ #3137.
2006-11-14  Jakub Jelinek  <jakub@redhat.com>
	* nss/nss_files/files-alias.c (get_next_alias): Set line back
	to first_unused after parsing :include: file.
	* timezone/africa: Update from tzdata2006o.
	* timezone/antarctica: Likewise.
	* timezone/asia: Likewise.
	* timezone/australasia: Likewise.
	* timezone/backward: Likewise.
	* timezone/europe: Likewise.
	* timezone/iso3166.tab: Likewise.
	* timezone/northamerica: Likewise.
	* timezone/southamerica: Likewise.
	* timezone/zone.tab: Likewise.

	* time/tzfile.c (__tzfile_read): Extend to handle new file format
	on machines with 64-bit time_t.

	* timezone/checktab.awk: Update from tzcode2006o.
	* timezone/ialloc.c: Likewise.
	* timezone/private.h: Likewise.
	* timezone/scheck.c: Likewise.
	* timezone/tzfile.h: Likewise.
	* timezone/tzselect.ksh: Likewise.
	* timezone/zdump.c: Likewise.
	* timezone/zic.c: Likewise.

	[BZ #3483]
	* elf/ldconfig.c (main): Call setlocale and textdomain.
	Patch mostly by Benno Schulenberg <bensberg@justemail.net>.

	[BZ #3480]
	* manual/argp.texi: Fix typos.
	* manual/charset.texi: Likewise.
	* manual/errno.texi: Likewise.
	* manual/filesys.texi: Likewise.
	* manual/lang.texi: Likewise.
	* manual/maint.texi: Likewise.
	* manual/memory.texi: Likewise.
	* manual/message.texi: Likewise.
	* manual/resource.texi: Likewise.
	* manual/search.texi: Likewise.
	* manual/signal.texi: Likewise.
	* manual/startup.texi: Likewise.
	* manual/stdio.texi: Likewise.
	* manual/sysinfo.texi: Likewise.
	* manual/syslog.texi: Likewise.
	* manual/time.texi: Likewise.
	Patch by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.

	[BZ #3465]
	* sunrpc/clnt_raw.c: Minimal message improvements.
	* sunrpc/pm_getmaps.c: Likewise.
	* nis/nss_nisplus/nisplus-publickey.c: Likewise.
	* nis/nis_print_group_entry.c: Likewise.
	* locale/programs/repertoire.c: Likewise.
	* locale/programs/charmap.c: Likewise.
	* malloc/memusage.sh: Likewise.
	* elf/dl-deps.c: Likewise.
	* locale/programs/ld-collate.c: Likewise.
	* libio/vswprintf.c: Likewise.
	* malloc/memusagestat.c: Likewise.
	* sunrpc/auth_unix.c: Likewise.
	* sunrpc/rpc_main.c: Likewise.
	* nscd/cache.c: Likewise.
	* locale/programs/repertoire.c: Unify output messages.
	* locale/programs/charmap.c: Likewise.
	* locale/programs/ld-ctype.c: Likewise.
	* locale/programs/ld-monetary.c: Likewise.
	* locale/programs/ld-numeric.c: Likewise.
	* locale/programs/ld-time.c: Likewise.
	* elf/ldconfig.c: Likewise.
	* nscd/selinux.c: Likewise.
	* elf/cache.c: Likewise.
	Patch mostly by Benno Schulenberg <bensberg@justemail.net>.

2006-11-10  Jakub Jelinek  <jakub@redhat.com>

	* string/strxfrm_l.c (STRXFRM): Fix trailing \1 optimization
	if N is one bigger than return value.
	* string/tst-strxfrm2.c (do_test): Also test strxfrm with l1 + 1
	and l1 last arguments, if buf is defined, verify the return value
	equals to strlen (buf) and verify no byte beyond passed length
	is modified.

2006-11-10  Ulrich Drepper  <drepper@redhat.com>

	* po/sv.po: Update from translation team.

	* sysdeps/gnu/siglist.c (__old_sys_siglist, __old_sys_sigabbrev):
	Use __new_sys_siglist instead of _sys_siglist_internal as
	second macro argument.
	(_old_sys_siglist): Use declare_symbol_alias macro instead of
	strong_alias.
2006-11-09  Ulrich Drepper  <drepper@redhat.com>

	[BZ #3493]
	* posix/unistd.h (sysconf): Remove const attribute.

	* sysdeps/posix/getaddrinfo.c (getaddrinfo): Fix test for
	temporary or deprecated addresses.
	Patch by Sridhar Samudrala <sri@us.ibm.com>.

	* string/Makefile (tests): Add tst-strxfrm2.
	* string/tst-strxfrm2.c: New file.

2006-10-09  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-debug.c (_dl_debug_initialize): Check r->r_map for 0
	rather than r->r_brk.
	* string/strxfrm_l.c (STRXFRM): Do the trailing \1 removal
	optimization even if needed > n.

2006-11-07  Jakub Jelinek  <jakub@redhat.com>

	* include/libc-symbols.h (declare_symbol): Rename to...
	(declare_symbol_alias): ... this.  Add ORIGINAL argument, imply
	strong_alias (ORIGINAL, SYMBOL) in asm to make sure it preceedes
	.size directive.
	* sysdeps/gnu/errlist-compat.awk: Adjust for declare_symbol_alias
	changes.
	* sysdeps/gnu/siglist.c: Likewise.

2006-11-03  Steven Munroe  <sjmunroe@us.ibm.com>

	* sysdeps/powerpc/fpu/bits/mathinline.h
	[__LIBC_INTERNAL_MATH_INLINES]: Moved to ...
	* sysdeps/powerpc/fpu/math_private.h: ...here.  New file.

2006-11-05  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/unix/sysv/linux/i386/sysconf.c (intel_check_word):
	Update handling of cache descriptor 0x49 for new models.
	* sysdeps/unix/sysv/linux/x86_64/sysconf.c (intel_check_word):
	Likewise.

2006-11-02  Ulrich Drepper  <drepper@redhat.com>

	* configure.in: Work around ld --help change and avoid -z relro
	test completely if the architecture doesn't care about security.

2006-11-01  Ulrich Drepper  <drepper@redhat.com>

	* po/sv.po: Update from translation team.

2006-10-31  Ulrich Drepper  <drepper@redhat.com>

	* stdlib/atexit.c (atexit): Don't mark as hidden when used to
	generate compatibility version.

2006-10-29  Ulrich Drepper  <drepper@redhat.com>

	* configure.in: Relax -z relro requirement a bit.

	* po/sv.po: Update from translation team.

2006-10-29  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-sym.c (do_sym): Use RTLD_SINGLE_THREAD_P.
	* elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Likewise.
	* elf/dl-close.c (_dl_close_worker): Likewise.
	* elf/dl-open.c (_dl_open_worker): Likewise.
	* sysdeps/generic/sysdep-cancel.h (RTLD_SINGLE_THREAD_P): Define.

	* configure.in: Require assembler support for visibility, compiler
	support for visibility and aliases, linker support for various -z
	options.
	* Makeconfig: Remove conditional code which now is unnecessary.
	* config.h.in: Likewise.
	* config.make.in: Likewise.
	* dlfcn/Makefile: Likewise.
	* elf/Makefile: Likewise.
	* elf/dl-load.c: Likewise.
	* elf/rtld.c: Likewise.
	* include/libc-symbols.h: Likewise.
	* include/stdio.h: Likewise.
	* io/Makefile: Likewise.
	* io/fstat.c: Likewise.
	* io/fstat64.c: Likewise.
	* io/fstatat.c: Likewise.
	* io/fstatat64.c: Likewise.
	* io/lstat.c: Likewise.
	* io/lstat64.c: Likewise.
	* io/mknod.c: Likewise.
	* io/mknodat.c: Likewise.
	* io/stat.c: Likewise.
	* io/stat64.c: Likewise.
	* libio/stdio.c: Likewise.
	* nscd/Makefile: Likewise.
	* stdlib/Makefile: Likewise.
	* stdlib/atexit.c: Likewise.
	* sysdeps/generic/ldsodefs.h: Likewise.
	* sysdeps/i386/dl-machine.h: Likewise.
	* sysdeps/i386/sysdep.h: Likewise.
	* sysdeps/i386/i686/memcmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/sigaction.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigaction.c: Likewise.

	* Makerules: USE_TLS support is now default.
	* tls.make.c: Likewise.
	* csu/Versions: Likewise.
	* csu/libc-start.c: Likewise.
	* csu/libc-tls.c: Likewise.
	* csu/version.c: Likewise.
	* dlfcn/dlinfo.c: Likewise.
	* elf/dl-addr.c: Likewise.
	* elf/dl-cache.c: Likewise.
	* elf/dl-close.c: Likewise.
	* elf/dl-iteratephdr.c: Likewise.
	* elf/dl-load.c: Likewise.
	* elf/dl-lookup.c: Likewise.
	* elf/dl-object.c: Likewise.
	* elf/dl-open.c: Likewise.
	* elf/dl-reloc.c: Likewise.
	* elf/dl-support.c: Likewise.
	* elf/dl-sym.c: Likewise.
	* elf/dl-sysdep.c: Likewise.
	* elf/dl-tls.c: Likewise.
	* elf/ldconfig.c: Likewise.
	* elf/rtld.c: Likewise.
	* elf/tst-tls-dlinfo.c: Likewise.
	* elf/tst-tls1.c: Likewise.
	* elf/tst-tls10.h: Likewise.
	* elf/tst-tls14.c: Likewise.
	* elf/tst-tls2.c: Likewise.
	* elf/tst-tls3.c: Likewise.
	* elf/tst-tls4.c: Likewise.
	* elf/tst-tls5.c: Likewise.
	* elf/tst-tls6.c: Likewise.
	* elf/tst-tls7.c: Likewise.
	* elf/tst-tls8.c: Likewise.
	* elf/tst-tls9.c: Likewise.
	* elf/tst-tlsmod1.c: Likewise.
	* elf/tst-tlsmod13.c: Likewise.
	* elf/tst-tlsmod13a.c: Likewise.
	* elf/tst-tlsmod14a.c: Likewise.
	* elf/tst-tlsmod2.c: Likewise.
	* elf/tst-tlsmod3.c: Likewise.
	* elf/tst-tlsmod4.c: Likewise.
	* elf/tst-tlsmod5.c: Likewise.
	* elf/tst-tlsmod6.c: Likewise.
	* include/errno.h: Likewise.
	* include/link.h: Likewise.
	* include/tls.h: Likewise.
	* locale/global-locale.c: Likewise.
	* locale/localeinfo.h: Likewise.
	* malloc/arena.c: Likewise.
	* malloc/hooks.c: Likewise.
	* malloc/malloc.c: Likewise.
	* resolv/Versions: Likewise.
	* sysdeps/alpha/dl-machine.h: Likewise.
	* sysdeps/alpha/libc-tls.c: Likewise.
	* sysdeps/generic/ldsodefs.h: Likewise.
	* sysdeps/generic/tls.h: Likewise.
	* sysdeps/i386/dl-machine.h: Likewise.
	* sysdeps/ia64/dl-machine.h: Likewise.
	* sysdeps/ia64/libc-tls.c: Likewise.
	* sysdeps/mach/hurd/fork.c: Likewise.
	* sysdeps/mach/hurd/i386/tls.h: Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.c: Likwise.
	* sysdeps/powerpc/powerpc32/dl-machine.h: Likewise.
	* sysdeps/powerpc/powerpc64/dl-machine.h: Likewise.
	* sysdeps/s390/libc-tls.c: Likewise.
	* sysdeps/s390/s390-32/dl-machine.h: Likewise.
	* sysdeps/s390/s390-64/dl-machine.h: Likewise.
	* sysdeps/sh/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc32/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc64/dl-machine.h: Likewise.
	* sysdeps/x86_64/dl-machine.h: Likewise.

	[BZ #3426]
	* stdlib/stdlib.h: Adjust comment for canonicalize_file_name to
	reality.

2006-10-27  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-lookup.c (_dl_debug_bindings): Remove unused symbol_scope
	argument.
	(_dl_lookup_symbol_x): Adjust caller.

	* sysdeps/generic/ldsodefs.h (struct link_namespaces): Remove
	_ns_global_scope.
	* elf/rtld.c (dl_main): Don't initialize _ns_global_scope.

	* elf/dl-libc.c: Revert l_scope name changes.
	* elf/dl-load.c: Likewise.
	* elf/dl-object.c: Likewise.
	* elf/rtld.c: Likewise.
	* elf/dl-close.c (_dl_close): Likewise.
	* elf/dl-open.c (dl_open_worker): Likewise.  If not SINGLE_THREAD_P,
	always use __rtld_mrlock_{change,done}.  Always free old scope list
	here if not l_scope_mem.
	* elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Revert l_scope name
	change.  Never free scope list here.  Just __rtld_mrlock_lock before
	the lookup and __rtld_mrlock_unlock it after the lookup.
	* elf/dl-sym.c: Likewise.
	* include/link.h (struct r_scoperec): Remove.
	(struct link_map): Replace l_scoperec with l_scope, l_scoperec_mem
	with l_scope_mem and l_scoperec_lock with l_scope_lock.

2006-10-25  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/gnu/netinet/tcp.h: Define TCP_CONGESTION.

2006-10-18  Ulrich Drepper  <drepper@redhat.com>

	* configure.in: Disable building profile libraries by default.

2006-10-18  Ulrich Drepper  <drepper@redhat.com>

	* elf/dl-lookup.c (_dl_lookup_symbol_x): Add warning to
	_dl_lookup_symbol_x code.

2006-10-17  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-runtime.c: Include sysdep-cancel.h.
	(_dl_fixup, _dl_profile_fixup): Use __rtld_mrlock_* and
	scoperec->nusers only if !SINGLE_THREAD_P.  Use atomic_*
	instead of catomic_* macros.
	* elf/dl-sym.c: Include sysdep-cancel.h.
	(do_sym): Use __rtld_mrlock_* and scoperec->nusers only
	if !SINGLE_THREAD_P.  Use atomic_* instead of catomic_* macros.
	* elf/dl-close.c: Include sysdep-cancel.h.
	(_dl_close): Use __rtld_mrlock_* and scoperec->nusers only
	if !SINGLE_THREAD_P.  Use atomic_* instead of catomic_* macros.
	* elf/dl-open.c: Include sysdep-cancel.h.
	(dl_open_worker): Use __rtld_mrlock_* and scoperec->nusers only
	if !SINGLE_THREAD_P.  Use atomic_* instead of catomic_* macros.

2006-10-17  Jakub Jelinek  <jakub@redhat.com>

	[BZ #3313]
	* malloc/malloc.c (malloc_consolidate): Set maxfb to address of last
	fastbin rather than end of fastbin array.

2006-10-18  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/i386/i486/bits/atomic.h (catomic_decrement): Use correct
	body macro.
	* sysdeps/x86_64/bits/atomic.h
	(__arch_c_compare_and_exchange_val_64_acq): Add missing casts.
	(catomic_decrement): Use correct body macro.

2006-10-17  Jakub Jelinek  <jakub@redhat.com>

	* include/atomic.h: Add a unique prefix to all local variables
	in macros.
	* csu/tst-atomic.c (do_test): Test also catomic_* macros.

2006-10-14  Ulrich Drepper  <drepper@redhat.com>

	* resolv/arpa/nameser.h: Document that ns_t_a6 is deprecated.

	[BZ #3313]
	* malloc/malloc.c (malloc_consolidate): Don't use get_fast_max to
	determine highest fast bin to consolidate, always look into all of
	them.
	(do_check_malloc_state): Only require for empty bins for large
	sizes in main arena.

	* libio/stdio.h: Add more __wur attributes.

2006-11-12  Andreas Jaeger  <aj@suse.de>

	[BZ #2510]
	* manual/search.texi (Hash Search Function): Clarify.
	(Array Search Function): Clarify.

2006-11-12  Joseph Myers  <joseph@codesourcery.com>

	[BZ #2830]
	* math/atest-exp.c (main): Cast hex value to mp_limb_t before
	shifting.
	* math/atest-exp2.c (read_mpn_hex): Likewise.
	* math/atest-sincos.c (main): Likewise.

	* sysdeps/unix/sysv/linux/syscalls.list: Add epoll_pwait.
	* sysdeps/unix/sysv/linux/sys/epoll.h: Declare epoll_pwait.
	* sysdeps/unix/sysv/linux/Versions (libc): Add epoll_pwait for
	version GLIBC_2.6.
	* Versions.def: Add GLIBC_2.6 for libc.

	* sysdeps/i386/i486/bits/atomic.h: Add catomic_* support.

2006-10-11  Jakub Jelinek  <jakub@redhat.com>

	* malloc/malloc.c (_int_malloc): Remove unused any_larger variable.

	* nis/nis_defaults.c (__nis_default_access): Don't call getenv twice.

	* nis/nis_subr.c (nis_getnames): Use __secure_getenv instead of getenv.
	* sysdeps/generic/unsecvars.h: Add NIS_PATH.

2006-10-11  Ulrich Drepper  <drepper@redhat.com>

	* include/atomic.c: Define catomic_* operations.
	* sysdeps/x86_64/bits/atomic.h: Likewise.  Fix a few minor problems.
	* stdlib/cxa_finalize.c: Use catomic_* operations instead of atomic_*.
	* malloc/memusage.c: Likewise.
	* gmon/mcount.c: Likewise.
	* elf/dl-close.c: Likewise.
	* elf/dl-open.c: Likewise.
	* elf/dl-profile.c: Likewise.
	* elf/dl-sym.c: Likewise.
	* elf/dl-runtime.c: Likewise.
	* elf/dl-fptr.c: Likewise.
	* resolv/res_libc.c: Likewise.

2006-10-10  Roland McGrath  <roland@frob.com>
	* sysdeps/mach/hurd/utimes.c: Use a union to avoid an improper cast.
	* sysdeps/mach/hurd/futimes.c: Likewise.
	* sysdeps/mach/hurd/lutimes.c: Likewise.

2006-10-09  Ulrich Drepper  <drepper@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>

	Implement reference counting of scope records.
	* elf/dl-close.c (_dl_close): Remove all scopes from removed objects
	from the list in objects which remain.  Always allocate new scope
	record.
	* elf/dl-open.c (dl_open_worker): When growing array for scopes,
	don't resize, allocate a new one.
	* elf/dl-runtime.c: Update reference counters before using a scope
	array.
	* elf/dl-sym.c: Likewise.
	* elf/dl-libc.c: Adjust for l_scope name change.
	* elf/dl-load.c: Likewise.
	* elf/dl-object.c: Likewise.
	* elf/rtld.c: Likewise.
	* include/link.h: Include <rtld-lowlevel.h>.  Define struct
	r_scoperec.  Replace r_scope with pointer to r_scoperec structure.
	Add l_scoperec_lock.
	* sysdeps/generic/ldsodefs.h: Include <rtld-lowlevel.h>.
	* sysdeps/generic/rtld-lowlevel.h: New file.

	* include/atomic.h: Rename atomic_and to atomic_and_val and
	atomic_or to atomic_or_val.  Define new macros atomic_and and
	atomic_or which do not return values.
	* sysdeps/x86_64/bits/atomic.h: Define atomic_and and atomic_or.
	Various cleanups.
	* sysdeps/i386/i486/bits/atomic.h: Likewise.

	* po/sv.po: Update from translation team.

2006-10-07  Ulrich Drepper  <drepper@redhat.com>

	* Versions.def: Add GLIBC_2.6 to libpthread.

	* include/shlib-compat.h (SHLIB_COMPAT): Expand parameters before use.
	(versioned_symbol): Likewise.
	(compat_symbol): Likewise.

	* po/tr.po: Update from translation team.
	* nis/Banner: Removed.  It's been integral part forever and the
	author info is incomplete anyway.
	* libio/Banner: Likewise.

2006-10-06  Ulrich Drepper  <drepper@redhat.com>

	* version.h (VERSION): Bump to 2.5.90 for new development tree.
2007-01-11 21:51:07 +00:00

1484 lines
36 KiB
C

/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
* program developed by the user or with the express written consent of
* Sun Microsystems, Inc.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
*
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
*
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
*
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
*
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
/*
* From @(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI;
*/
/*
* rpc_main.c, Top level of the RPC protocol compiler.
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <libintl.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include "rpc_parse.h"
#include "rpc_util.h"
#include "rpc_scan.h"
#include "proto.h"
#define EXTEND 1 /* alias for TRUE */
#define DONT_EXTEND 0 /* alias for FALSE */
struct commandline
{
int cflag; /* xdr C routines */
int hflag; /* header file */
int lflag; /* client side stubs */
int mflag; /* server side stubs */
int nflag; /* netid flag */
int sflag; /* server stubs for the given transport */
int tflag; /* dispatch Table file */
int Ssflag; /* produce server sample code */
int Scflag; /* produce client sample code */
int makefileflag; /* Generate a template Makefile */
const char *infile; /* input module name */
const char *outfile; /* output module name */
};
static const char *cmdname;
#define SVR4_CPP "/usr/ccs/lib/cpp"
#define SUNOS_CPP "/lib/cpp"
static const char *svcclosetime = "120";
static int cppDefined; /* explicit path for C preprocessor */
static const char *CPP = SUNOS_CPP;
static const char CPPFLAGS[] = "-C";
static char *pathbuf;
static int cpp_pid;
static const char *allv[] =
{
"rpcgen", "-s", "udp", "-s", "tcp"
};
static int allc = sizeof (allv) / sizeof (allv[0]);
static const char *allnv[] =
{
"rpcgen", "-s", "netpath",
};
static int allnc = sizeof (allnv) / sizeof (allnv[0]);
/*
* machinations for handling expanding argument list
*/
static void addarg (const char *); /* add another argument to the list */
static void putarg (int, const char *); /* put argument at specified location */
static void clear_args (void); /* clear argument list */
static void checkfiles (const char *, const char *);
/* check if out file already exists */
static void clear_args (void);
static char *extendfile (const char *file, const char *ext);
static void open_output (const char *infile, const char *outfile);
static void add_warning (void);
static void clear_args (void);
static void find_cpp (void);
static void open_input (const char *infile, const char *define);
static int check_nettype (const char *name, const char *list_to_check[]);
static void c_output (const char *infile, const char *define,
int extend, const char *outfile);
static void h_output (const char *infile, const char *define,
int extend, const char *outfile);
static void s_output (int argc, const char *argv[], const char *infile,
const char *define, int extend,
const char *outfile, int nomain, int netflag);
static void l_output (const char *infile, const char *define,
int extend, const char *outfile);
static void t_output (const char *infile, const char *define,
int extend, const char *outfile);
static void svc_output (const char *infile, const char *define,
int extend, const char *outfile);
static void clnt_output (const char *infile, const char *define,
int extend, const char *outfile);
static void mkfile_output (struct commandline *cmd);
static int do_registers (int argc, const char *argv[]);
static void addarg (const char *cp);
static void putarg (int whereto, const char *cp);
static void checkfiles (const char *infile, const char *outfile);
static int parseargs (int argc, const char *argv[], struct commandline *cmd);
static void usage (void) __attribute__ ((noreturn));
static void options_usage (void) __attribute__ ((noreturn));
static void c_initialize (void);
static char *generate_guard (const char *pathname);
#define ARGLISTLEN 20
#define FIXEDARGS 2
static const char *arglist[ARGLISTLEN];
static int argcount = FIXEDARGS;
int nonfatalerrors; /* errors */
int inetdflag /* = 1 */ ; /* Support for inetd *//* is now the default */
int pmflag; /* Support for port monitors */
int logflag; /* Use syslog instead of fprintf for errors */
int tblflag; /* Support for dispatch table file */
int mtflag; /* Support for MT */
#define INLINE 3
/*length at which to start doing an inline */
int inlineflag = INLINE; /* length at which to start doing an inline. 3 = default
if 0, no xdr_inline code */
int indefinitewait; /* If started by port monitors, hang till it wants */
int exitnow; /* If started by port monitors, exit after the call */
int timerflag; /* TRUE if !indefinite && !exitnow */
int newstyle; /* newstyle of passing arguments (by value) */
#ifdef __GNU_LIBRARY__
int Cflag = 1; /* ANSI C syntax */
#else
int Cflag; /* ANSI C/C++ syntax */
#endif
int CCflag; /* C++ files */
static int allfiles; /* generate all files */
#ifdef __GNU_LIBRARY__
int tirpcflag; /* generating code for tirpc, by default */
#else
int tirpcflag = 1; /* generating code for tirpc, by default */
#endif
xdrfunc *xdrfunc_head; /* xdr function list */
xdrfunc *xdrfunc_tail; /* xdr function list */
int
main (int argc, const char *argv[])
{
struct commandline cmd;
(void) memset ((char *) &cmd, 0, sizeof (struct commandline));
clear_args ();
if (!parseargs (argc, argv, &cmd))
usage ();
if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||
cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag)
{
checkfiles (cmd.infile, cmd.outfile);
}
else
checkfiles (cmd.infile, NULL);
if (cmd.cflag)
c_output (cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
else if (cmd.hflag)
h_output (cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile);
else if (cmd.lflag)
l_output (cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
else if (cmd.sflag || cmd.mflag || (cmd.nflag))
s_output (argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
cmd.outfile, cmd.mflag, cmd.nflag);
else if (cmd.tflag)
t_output (cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
else if (cmd.Ssflag)
svc_output (cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);
else if (cmd.Scflag)
clnt_output (cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);
else if (cmd.makefileflag)
mkfile_output (&cmd);
else
{
/* the rescans are required, since cpp may effect input */
c_output (cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
reinitialize ();
h_output (cmd.infile, "-DRPC_HDR", EXTEND, ".h");
reinitialize ();
l_output (cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
reinitialize ();
if (inetdflag || !tirpcflag)
s_output (allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
"_svc.c", cmd.mflag, cmd.nflag);
else
s_output (allnc, allnv, cmd.infile, "-DRPC_SVC",
EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
if (tblflag)
{
reinitialize ();
t_output (cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
}
if (allfiles)
{
reinitialize ();
svc_output (cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");
reinitialize ();
clnt_output (cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
}
if (allfiles || (cmd.makefileflag == 1))
{
reinitialize ();
mkfile_output (&cmd);
}
}
return nonfatalerrors;
}
/*
* add extension to filename
*/
static char *
extendfile (const char *file, const char *ext)
{
char *res;
const char *p;
res = alloc (strlen (file) + strlen (ext) + 1);
if (res == NULL)
abort ();
p = strrchr (file, '.');
if (p == NULL)
p = file + strlen (file);
strcpy (res, file);
strcpy (res + (p - file), ext);
return res;
}
/*
* Open output file with given extension
*/
static void
open_output (const char *infile, const char *outfile)
{
if (outfile == NULL)
{
fout = stdout;
return;
}
if (infile != NULL && streq (outfile, infile))
{
fprintf (stderr, _ ("%s: output would overwrite %s\n"), cmdname,
infile);
crash ();
}
fout = fopen (outfile, "w");
if (fout == NULL)
{
fprintf (stderr, _ ("%s: unable to open %s: %m\n"), cmdname, outfile);
crash ();
}
record_open (outfile);
}
/* Close the output file and check for write errors. */
static void
close_output (const char *outfile)
{
if (fclose (fout) == EOF)
{
fprintf (stderr, _("%s: while writing output %s: %m"), cmdname,
outfile ?: "<stdout>");
crash ();
}
}
static void
add_warning (void)
{
fprintf (fout, "/*\n");
fprintf (fout, " * Please do not edit this file.\n");
fprintf (fout, " * It was generated using rpcgen.\n");
fprintf (fout, " */\n\n");
}
/* clear list of arguments */
static void
clear_args (void)
{
int i;
for (i = FIXEDARGS; i < ARGLISTLEN; ++i)
arglist[i] = NULL;
argcount = FIXEDARGS;
}
/* make sure that a CPP exists */
static void
find_cpp (void)
{
struct stat buf;
if (stat (CPP, &buf) < 0)
{ /* /lib/cpp or explicit cpp does not exist */
if (cppDefined)
{
fprintf (stderr, _ ("cannot find C preprocessor: %s \n"), CPP);
crash ();
}
else
{ /* try the other one */
CPP = SVR4_CPP;
if (stat (CPP, &buf) < 0)
{ /* can't find any cpp */
fputs (_ ("cannot find any C preprocessor (cpp)\n"), stdout);
crash ();
}
}
}
}
/*
* Open input file with given define for C-preprocessor
*/
static void
open_input (const char *infile, const char *define)
{
int pd[2];
infilename = (infile == NULL) ? "<stdin>" : infile;
if (pipe (pd) != 0)
{
perror ("pipe");
exit (1);
}
cpp_pid = fork ();
switch (cpp_pid)
{
case 0:
find_cpp ();
putarg (0, CPP);
putarg (1, CPPFLAGS);
addarg (define);
if (infile)
addarg (infile);
addarg ((char *) NULL);
close (1);
dup2 (pd[1], 1);
close (pd[0]);
execv (arglist[0], (char **) arglist);
perror ("execv");
exit (1);
case -1:
perror ("fork");
exit (1);
}
close (pd[1]);
fin = fdopen (pd[0], "r");
if (fin == NULL)
{
fprintf (stderr, "%s: ", cmdname);
perror (infilename);
crash ();
}
}
/* Close the connection to the C-preprocessor and check for successfull
termination. */
static void
close_input (void)
{
int status;
fclose (fin);
/* Check the termination status. */
if (waitpid (cpp_pid, &status, 0) < 0)
{
perror ("waitpid");
crash ();
}
if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0)
{
if (WIFSIGNALED (status))
fprintf (stderr, _("%s: C preprocessor failed with signal %d\n"),
cmdname, WTERMSIG (status));
else
fprintf (stderr, _("%s: C preprocessor failed with exit code %d\n"),
cmdname, WEXITSTATUS (status));
crash ();
}
}
/* valid tirpc nettypes */
static const char *valid_ti_nettypes[] =
{
"netpath",
"visible",
"circuit_v",
"datagram_v",
"circuit_n",
"datagram_n",
"udp",
"tcp",
"raw",
NULL
};
/* valid inetd nettypes */
static const char *valid_i_nettypes[] =
{
"udp",
"tcp",
NULL
};
static int
check_nettype (const char *name, const char *list_to_check[])
{
int i;
for (i = 0; list_to_check[i] != NULL; i++)
{
if (strcmp (name, list_to_check[i]) == 0)
{
return 1;
}
}
fprintf (stderr, _ ("illegal nettype: `%s'\n"), name);
return 0;
}
/*
* Compile into an XDR routine output file
*/
static void
c_output (const char *infile, const char *define, int extend,
const char *outfile)
{
definition *def;
char *include;
const char *outfilename;
long tell;
c_initialize ();
open_input (infile, define);
outfilename = extend ? extendfile (infile, outfile) : outfile;
open_output (infile, outfilename);
add_warning ();
if (infile && (include = extendfile (infile, ".h")))
{
fprintf (fout, "#include \"%s\"\n", include);
free (include);
/* .h file already contains rpc/rpc.h */
}
else
fprintf (fout, "#include <rpc/rpc.h>\n");
tell = ftell (fout);
while ((def = get_definition ()) != NULL)
emit (def);
if (extend && tell == ftell (fout))
unlink (outfilename);
close_input ();
close_output (outfilename);
}
void
c_initialize (void)
{
/* add all the starting basic types */
add_type (1, "int");
add_type (1, "long");
add_type (1, "short");
add_type (1, "bool");
add_type (1, "u_int");
add_type (1, "u_long");
add_type (1, "u_short");
}
char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
char *(*proc)();\n\
xdrproc_t xdr_arg;\n\
unsigned len_arg;\n\
xdrproc_t xdr_res;\n\
unsigned len_res;\n\
};\n";
static char *
generate_guard (const char *pathname)
{
const char *filename;
char *guard, *tmp;
filename = strrchr (pathname, '/'); /* find last component */
filename = ((filename == NULL) ? pathname : filename + 1);
guard = extendfile (filename, "_H_RPCGEN");
/* convert to upper case */
tmp = guard;
while (*tmp)
{
if (islower (*tmp))
*tmp = toupper (*tmp);
tmp++;
}
return guard;
}
/*
* Compile into an XDR header file
*/
static void
h_output (const char *infile, const char *define, int extend,
const char *outfile)
{
xdrfunc *xdrfuncp;
definition *def;
const char *ifilename;
const char *outfilename;
long tell;
char *guard;
list *l;
open_input (infile, define);
outfilename = extend ? extendfile (infile, outfile) : outfile;
open_output (infile, outfilename);
add_warning ();
ifilename = (infile == NULL) ? "STDIN" : infile;
guard = generate_guard (outfilename ? outfilename : ifilename);
fprintf (fout, "#ifndef _%s\n#define _%s\n\n", guard,
guard);
fprintf (fout, "#include <rpc/rpc.h>\n\n");
if (mtflag)
{
fprintf (fout, "#include <pthread.h>\n");
}
/* put the C++ support */
if (Cflag && !CCflag)
{
fprintf (fout, "\n#ifdef __cplusplus\n");
fprintf (fout, "extern \"C\" {\n");
fprintf (fout, "#endif\n\n");
}
tell = ftell (fout);
/* print data definitions */
while ((def = get_definition ()) != NULL)
{
print_datadef (def);
}
/* print function declarations.
Do this after data definitions because they might be used as
arguments for functions */
for (l = defined; l != NULL; l = l->next)
{
print_funcdef (l->val);
}
/* Now print all xdr func declarations */
if (xdrfunc_head != NULL)
{
fprintf (fout, "\n/* the xdr functions */\n");
if (CCflag)
{
fprintf (fout, "\n#ifdef __cplusplus\n");
fprintf (fout, "extern \"C\" {\n");
fprintf (fout, "#endif\n");
}
if (!Cflag)
{
xdrfuncp = xdrfunc_head;
while (xdrfuncp != NULL)
{
print_xdr_func_def (xdrfuncp->name,
xdrfuncp->pointerp, 2);
xdrfuncp = xdrfuncp->next;
}
}
else
{
int i;
for (i = 1; i < 3; ++i)
{
if (i == 1)
fprintf (fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n");
else
fprintf (fout, "\n#else /* K&R C */\n");
xdrfuncp = xdrfunc_head;
while (xdrfuncp != NULL)
{
print_xdr_func_def (xdrfuncp->name,
xdrfuncp->pointerp, i);
xdrfuncp = xdrfuncp->next;
}
}
fprintf (fout, "\n#endif /* K&R C */\n");
}
}
if (extend && tell == ftell (fout))
{
unlink (outfilename);
}
else if (tblflag)
{
fprintf (fout, rpcgen_table_dcl);
}
if (Cflag)
{
fprintf (fout, "\n#ifdef __cplusplus\n");
fprintf (fout, "}\n");
fprintf (fout, "#endif\n");
}
fprintf (fout, "\n#endif /* !_%s */\n", guard);
free (guard);
close_input ();
close_output (outfilename);
}
/*
* Compile into an RPC service
*/
static void
s_output (int argc, const char *argv[], const char *infile, const char *define,
int extend, const char *outfile, int nomain, int netflag)
{
char *include;
definition *def;
int foundprogram = 0;
const char *outfilename;
open_input (infile, define);
outfilename = extend ? extendfile (infile, outfile) : outfile;
open_output (infile, outfilename);
add_warning ();
if (infile && (include = extendfile (infile, ".h")))
{
fprintf (fout, "#include \"%s\"\n", include);
free (include);
}
else
fprintf (fout, "#include <rpc/rpc.h>\n");
fprintf (fout, "#include <stdio.h>\n");
fprintf (fout, "#include <stdlib.h>\n");
fprintf (fout, "#include <rpc/pmap_clnt.h>\n");
if (Cflag)
fprintf (fout, "#include <string.h>\n");
if (strcmp (svcclosetime, "-1") == 0)
indefinitewait = 1;
else if (strcmp (svcclosetime, "0") == 0)
exitnow = 1;
else if (inetdflag || pmflag)
{
fprintf (fout, "#include <signal.h>\n");
timerflag = 1;
}
if (!tirpcflag && inetdflag)
#ifdef __GNU_LIBRARY__
fprintf (fout, "#include <sys/ioctl.h> /* ioctl, TIOCNOTTY */\n");
#else
fprintf (fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
#endif
if (Cflag && (inetdflag || pmflag))
{
#ifdef __GNU_LIBRARY__
fprintf (fout, "#include <sys/types.h> /* open */\n");
fprintf (fout, "#include <sys/stat.h> /* open */\n");
fprintf (fout, "#include <fcntl.h> /* open */\n");
fprintf (fout, "#include <unistd.h> /* getdtablesize */\n");
#else
fprintf (fout, "#ifdef __cplusplus\n");
fprintf (fout, "#include <sysent.h> /* getdtablesize, open */\n");
fprintf (fout, "#endif /* __cplusplus */\n");
if (tirpcflag)
fprintf (fout, "#include <unistd.h> /* setsid */\n");
#endif
}
#ifdef __GNU_LIBRARY__
if (tirpcflag && !(Cflag && (inetdflag || pmflag)))
#else
if (tirpcflag)
#endif
fprintf (fout, "#include <sys/types.h>\n");
fprintf (fout, "#include <memory.h>\n");
#ifndef __GNU_LIBRARY__
fprintf (fout, "#include <stropts.h>\n");
#endif
if (inetdflag || !tirpcflag)
{
fprintf (fout, "#include <sys/socket.h>\n");
fprintf (fout, "#include <netinet/in.h>\n");
}
if ((netflag || pmflag) && tirpcflag && !nomain)
{
fprintf (fout, "#include <netconfig.h>\n");
}
if ( /*timerflag && */ tirpcflag)
fprintf (fout, "#include <sys/resource.h> /* rlimit */\n");
if (logflag || inetdflag || pmflag)
{
#ifdef __GNU_LIBRARY__
fprintf (fout, "#include <syslog.h>\n");
#else
fprintf (fout, "#ifdef SYSLOG\n");
fprintf (fout, "#include <syslog.h>\n");
fprintf (fout, "#else\n");
fprintf (fout, "#define LOG_ERR 1\n");
fprintf (fout, "#define openlog(a, b, c)\n");
fprintf (fout, "#endif\n");
#endif
}
/* for ANSI-C */
if (Cflag)
fprintf (fout, "\n#ifndef SIG_PF\n#define SIG_PF void(*)(int)\n#endif\n");
#ifndef __GNU_LIBRARY__
fprintf (fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
#endif
if (timerflag)
fprintf (fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime);
while ((def = get_definition ()) != NULL)
{
foundprogram |= (def->def_kind == DEF_PROGRAM);
}
if (extend && !foundprogram)
{
unlink (outfilename);
return;
}
write_most (infile, netflag, nomain);
if (!nomain)
{
if (!do_registers (argc, argv))
{
if (outfilename)
unlink (outfilename);
usage ();
}
write_rest ();
}
close_input ();
close_output (outfilename);
}
/*
* generate client side stubs
*/
static void
l_output (const char *infile, const char *define, int extend,
const char *outfile)
{
char *include;
definition *def;
int foundprogram = 0;
const char *outfilename;
open_input (infile, define);
outfilename = extend ? extendfile (infile, outfile) : outfile;
open_output (infile, outfilename);
add_warning ();
if (Cflag)
fprintf (fout, "#include <memory.h> /* for memset */\n");
if (infile && (include = extendfile (infile, ".h")))
{
fprintf (fout, "#include \"%s\"\n", include);
free (include);
}
else
fprintf (fout, "#include <rpc/rpc.h>\n");
while ((def = get_definition ()) != NULL)
{
foundprogram |= (def->def_kind == DEF_PROGRAM);
}
if (extend && !foundprogram)
{
unlink (outfilename);
return;
}
write_stubs ();
close_input ();
close_output (outfilename);
}
/*
* generate the dispatch table
*/
static void
t_output (const char *infile, const char *define, int extend,
const char *outfile)
{
definition *def;
int foundprogram = 0;
const char *outfilename;
open_input (infile, define);
outfilename = extend ? extendfile (infile, outfile) : outfile;
open_output (infile, outfilename);
add_warning ();
while ((def = get_definition ()) != NULL)
{
foundprogram |= (def->def_kind == DEF_PROGRAM);
}
if (extend && !foundprogram)
{
unlink (outfilename);
return;
}
write_tables ();
close_input ();
close_output (outfilename);
}
/* sample routine for the server template */
static void
svc_output (const char *infile, const char *define, int extend,
const char *outfile)
{
definition *def;
char *include;
const char *outfilename;
long tell;
open_input (infile, define);
outfilename = extend ? extendfile (infile, outfile) : outfile;
checkfiles (infile, outfilename);
/*check if outfile already exists.
if so, print an error message and exit */
open_output (infile, outfilename);
add_sample_msg ();
if (infile && (include = extendfile (infile, ".h")))
{
fprintf (fout, "#include \"%s\"\n", include);
free (include);
}
else
fprintf (fout, "#include <rpc/rpc.h>\n");
tell = ftell (fout);
while ((def = get_definition ()) != NULL)
{
write_sample_svc (def);
}
if (extend && tell == ftell (fout))
{
unlink (outfilename);
}
close_input ();
close_output (outfilename);
}
/* sample main routine for client */
static void
clnt_output (const char *infile, const char *define, int extend,
const char *outfile)
{
definition *def;
char *include;
const char *outfilename;
long tell;
int has_program = 0;
open_input (infile, define);
outfilename = extend ? extendfile (infile, outfile) : outfile;
checkfiles (infile, outfilename);
/*check if outfile already exists.
if so, print an error message and exit */
open_output (infile, outfilename);
add_sample_msg ();
if (infile && (include = extendfile (infile, ".h")))
{
fprintf (fout, "#include \"%s\"\n", include);
free (include);
}
else
fprintf (fout, "#include <rpc/rpc.h>\n");
tell = ftell (fout);
while ((def = get_definition ()) != NULL)
{
has_program += write_sample_clnt (def);
}
if (has_program)
write_sample_clnt_main ();
if (extend && tell == ftell (fout))
{
unlink (outfilename);
}
close_input ();
close_output (outfilename);
}
static const char space[] = " ";
static char *
file_name (const char *file, const char *ext)
{
char *temp;
temp = extendfile (file, ext);
if (access (temp, F_OK) != -1)
return (temp);
free (temp);
return (char *) space;
}
static void
mkfile_output (struct commandline *cmd)
{
char *mkfilename;
char *clientname, *clntname, *xdrname, *hdrname;
char *servername, *svcname, *servprogname, *clntprogname;
svcname = file_name (cmd->infile, "_svc.c");
clntname = file_name (cmd->infile, "_clnt.c");
xdrname = file_name (cmd->infile, "_xdr.c");
hdrname = file_name (cmd->infile, ".h");
if (allfiles)
{
servername = extendfile (cmd->infile, "_server.c");
clientname = extendfile (cmd->infile, "_client.c");
}
else
{
servername = (char *) space;
clientname = (char *) space;
}
servprogname = extendfile (cmd->infile, "_server");
clntprogname = extendfile (cmd->infile, "_client");
if (allfiles)
{
char *cp, *temp;
mkfilename = alloc (strlen ("Makefile.") + strlen (cmd->infile) + 1);
if (mkfilename == NULL)
abort ();
temp = rindex (cmd->infile, '.');
cp = stpcpy (mkfilename, "Makefile.");
strncpy (cp, cmd->infile, (temp - cmd->infile));
}
else
mkfilename = (char *) cmd->outfile;
checkfiles (NULL, mkfilename);
open_output (NULL, mkfilename);
fprintf (fout, "\n# This is a template Makefile generated by rpcgen\n");
f_print (fout, "\n# Parameters\n\n");
f_print (fout, "CLIENT = %s\nSERVER = %s\n\n", clntprogname, servprogname);
f_print (fout, "SOURCES_CLNT.c = \nSOURCES_CLNT.h = \n");
f_print (fout, "SOURCES_SVC.c = \nSOURCES_SVC.h = \n");
f_print (fout, "SOURCES.x = %s\n\n", cmd->infile);
f_print (fout, "TARGETS_SVC.c = %s %s %s \n",
svcname, servername, xdrname);
f_print (fout, "TARGETS_CLNT.c = %s %s %s \n",
clntname, clientname, xdrname);
f_print (fout, "TARGETS = %s %s %s %s %s %s\n\n",
hdrname, xdrname, clntname,
svcname, clientname, servername);
f_print (fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) \
$(TARGETS_CLNT.c:%%.c=%%.o)");
f_print (fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) \
$(TARGETS_SVC.c:%%.c=%%.o)");
f_print (fout, "\n# Compiler flags \n");
if (mtflag)
fprintf (fout, "\nCPPFLAGS += -D_REENTRANT\nCFLAGS += -g \nLDLIBS \
+= -lnsl -lpthread \n ");
else
f_print (fout, "\nCFLAGS += -g \nLDLIBS += -lnsl\n");
f_print (fout, "RPCGENFLAGS = \n");
f_print (fout, "\n# Targets \n\n");
f_print (fout, "all : $(CLIENT) $(SERVER)\n\n");
f_print (fout, "$(TARGETS) : $(SOURCES.x) \n");
f_print (fout, "\trpcgen $(RPCGENFLAGS) $(SOURCES.x)\n\n");
f_print (fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) \
$(TARGETS_CLNT.c) \n\n");
f_print (fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) \
$(TARGETS_SVC.c) \n\n");
f_print (fout, "$(CLIENT) : $(OBJECTS_CLNT) \n");
f_print (fout, "\t$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) \
$(LDLIBS) \n\n");
f_print (fout, "$(SERVER) : $(OBJECTS_SVC) \n");
f_print (fout, "\t$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n ");
f_print (fout, "clean:\n\t $(RM) core $(TARGETS) $(OBJECTS_CLNT) \
$(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n");
close_output (mkfilename);
free (clntprogname);
free (servprogname);
if (servername != space)
free (servername);
if (clientname != space)
free (clientname);
if (mkfilename != (char *) cmd->outfile)
free (mkfilename);
if (svcname != space)
free (svcname);
if (clntname != space)
free (clntname);
if (xdrname != space)
free (xdrname);
if (hdrname != space)
free (hdrname);
}
/*
* Perform registrations for service output
* Return 0 if failed; 1 otherwise.
*/
static int
do_registers (int argc, const char *argv[])
{
int i;
if (inetdflag || !tirpcflag)
{
for (i = 1; i < argc; i++)
{
if (streq (argv[i], "-s"))
{
if (!check_nettype (argv[i + 1], valid_i_nettypes))
return 0;
write_inetd_register (argv[i + 1]);
i++;
}
}
}
else
{
for (i = 1; i < argc; i++)
if (streq (argv[i], "-s"))
{
if (!check_nettype (argv[i + 1], valid_ti_nettypes))
return 0;
write_nettype_register (argv[i + 1]);
i++;
}
else if (streq (argv[i], "-n"))
{
write_netid_register (argv[i + 1]);
i++;
}
}
return 1;
}
/*
* Add another argument to the arg list
*/
static void
addarg (const char *cp)
{
if (argcount >= ARGLISTLEN)
{
fprintf (stderr, _("rpcgen: too many defines\n"));
crash ();
/*NOTREACHED */
}
arglist[argcount++] = cp;
}
static void
putarg (int whereto, const char *cp)
{
if (whereto >= ARGLISTLEN)
{
fprintf (stderr, _("rpcgen: arglist coding error\n"));
crash ();
/*NOTREACHED */
}
arglist[whereto] = cp;
}
/*
* if input file is stdin and an output file is specified then complain
* if the file already exists. Otherwise the file may get overwritten
* If input file does not exist, exit with an error
*/
static void
checkfiles (const char *infile, const char *outfile)
{
struct stat buf;
if (infile) /* infile ! = NULL */
if (stat (infile, &buf) < 0)
{
perror (infile);
crash ();
}
if (outfile)
{
if (stat (outfile, &buf) < 0)
return; /* file does not exist */
else
{
fprintf (stderr,
/* TRANS: the file will not be removed; this is an
TRANS: informative message. */
_("file `%s' already exists and may be overwritten\n"),
outfile);
crash ();
}
}
}
/*
* Parse command line arguments
*/
static int
parseargs (int argc, const char *argv[], struct commandline *cmd)
{
int i;
int j;
int c;
char flag[(1 << 8 * sizeof (char))];
int nflags;
cmdname = argv[0];
cmd->infile = cmd->outfile = NULL;
if (argc < 2)
{
return (0);
}
allfiles = 0;
flag['c'] = 0;
flag['h'] = 0;
flag['l'] = 0;
flag['m'] = 0;
flag['o'] = 0;
flag['s'] = 0;
flag['n'] = 0;
flag['t'] = 0;
flag['S'] = 0;
flag['C'] = 0;
flag['M'] = 0;
for (i = 1; i < argc; i++)
{
if (argv[i][0] != '-')
{
if (cmd->infile)
{
fprintf (stderr,
_("Cannot specify more than one input file!\n"));
return 0;
}
cmd->infile = argv[i];
}
else
{
for (j = 1; argv[i][j] != 0; j++)
{
c = argv[i][j];
switch (c)
{
case 'a':
allfiles = 1;
break;
case 'c':
case 'h':
case 'l':
case 'm':
case 't':
if (flag[c])
return 0;
flag[c] = 1;
break;
case 'S':
/* sample flag: Ss or Sc.
Ss means set flag['S'];
Sc means set flag['C'];
Sm means set flag['M']; */
c = argv[i][++j]; /* get next char */
if (c == 's')
c = 'S';
else if (c == 'c')
c = 'C';
else if (c == 'm')
c = 'M';
else
return 0;
if (flag[c])
return 0;
flag[c] = 1;
break;
case 'C': /* ANSI C syntax */
Cflag = 1;
break;
#ifdef __GNU_LIBRARY__
case 'k': /* K&R C syntax */
Cflag = 0;
break;
#endif
case 'b': /* turn TIRPC flag off for
generating backward compatible
*/
tirpcflag = 0;
break;
#ifdef __GNU_LIBRARY__
case '5': /* turn TIRPC flag on for
generating SysVr4 compatible
*/
tirpcflag = 1;
break;
#endif
case 'I':
inetdflag = 1;
break;
case 'N':
newstyle = 1;
break;
case 'L':
logflag = 1;
break;
case 'K':
if (++i == argc)
{
return (0);
}
svcclosetime = argv[i];
goto nextarg;
case 'T':
tblflag = 1;
break;
case 'M':
mtflag = 1;
break;
case 'i':
if (++i == argc)
{
return (0);
}
inlineflag = atoi (argv[i]);
goto nextarg;
case 'n':
case 'o':
case 's':
if (argv[i][j - 1] != '-' ||
argv[i][j + 1] != 0)
{
return (0);
}
flag[c] = 1;
if (++i == argc)
{
return (0);
}
if (c == 's')
{
if (!streq (argv[i], "udp") &&
!streq (argv[i], "tcp"))
return 0;
}
else if (c == 'o')
{
if (cmd->outfile)
return 0;
cmd->outfile = argv[i];
}
goto nextarg;
case 'D':
if (argv[i][j - 1] != '-')
return 0;
addarg (argv[i]);
goto nextarg;
case 'Y':
if (++i == argc)
return 0;
{
size_t len = strlen (argv[i]);
pathbuf = malloc (len + 5);
if (pathbuf == NULL)
{
perror (cmdname);
crash ();
}
stpcpy (stpcpy (pathbuf,
argv[i]),
"/cpp");
CPP = pathbuf;
cppDefined = 1;
goto nextarg;
}
default:
return 0;
}
}
nextarg:
;
}
}
cmd->cflag = flag['c'];
cmd->hflag = flag['h'];
cmd->lflag = flag['l'];
cmd->mflag = flag['m'];
cmd->nflag = flag['n'];
cmd->sflag = flag['s'];
cmd->tflag = flag['t'];
cmd->Ssflag = flag['S'];
cmd->Scflag = flag['C'];
cmd->makefileflag = flag['M'];
#ifndef _RPC_THREAD_SAFE_
if (mtflag || newstyle)
{
/* glibc doesn't support these flags. */
f_print (stderr,
_("This implementation doesn't support newstyle or MT-safe code!\n"));
return (0);
}
#endif
if (tirpcflag)
{
pmflag = inetdflag ? 0 : 1; /* pmflag or inetdflag is always TRUE */
if ((inetdflag && cmd->nflag))
{ /* netid not allowed with inetdflag */
fprintf (stderr, _("Cannot use netid flag with inetd flag!\n"));
return 0;
}
}
else
{ /* 4.1 mode */
pmflag = 0; /* set pmflag only in tirpcmode */
#ifndef __GNU_LIBRARY__
inetdflag = 1; /* inetdflag is TRUE by default */
#endif
if (cmd->nflag)
{ /* netid needs TIRPC */
f_print (stderr, _("Cannot use netid flag without TIRPC!\n"));
return (0);
}
}
if (newstyle && (tblflag || cmd->tflag))
{
f_print (stderr, _("Cannot use table flags with newstyle!\n"));
return (0);
}
/* check no conflicts with file generation flags */
nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag +
cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag;
if (nflags == 0)
{
if (cmd->outfile != NULL || cmd->infile == NULL)
{
return (0);
}
}
else if (cmd->infile == NULL &&
(cmd->Ssflag || cmd->Scflag || cmd->makefileflag))
{
fprintf (stderr,
_("\"infile\" is required for template generation flags.\n"));
return 0;
}
if (nflags > 1)
{
fprintf (stderr, _("Cannot have more than one file generation flag!\n"));
return 0;
}
return 1;
}
static void
usage (void)
{
fprintf (stderr, _("usage: %s infile\n"), cmdname);
fprintf (stderr, _("\t%s [-abkCLNTM][-Dname[=value]] [-i size] \
[-I [-K seconds]] [-Y path] infile\n"), cmdname);
fprintf (stderr, _("\t%s [-c | -h | -l | -m | -t | -Sc | -Ss | -Sm] \
[-o outfile] [infile]\n"), cmdname);
fprintf (stderr, _("\t%s [-s nettype]* [-o outfile] [infile]\n"), cmdname);
fprintf (stderr, _("\t%s [-n netid]* [-o outfile] [infile]\n"), cmdname);
options_usage ();
exit (1);
}
static void
options_usage (void)
{
f_print (stderr, "options:\n");
f_print (stderr, "-a\t\tgenerate all files, including samples\n");
f_print (stderr, "-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n");
f_print (stderr, "-c\t\tgenerate XDR routines\n");
f_print (stderr, "-C\t\tANSI C mode\n");
f_print (stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n");
f_print (stderr, "-h\t\tgenerate header file\n");
f_print (stderr, "-i size\t\tsize at which to start generating inline code\n");
f_print (stderr, "-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n");
f_print (stderr, "-K seconds\tserver exits after K seconds of inactivity\n");
f_print (stderr, "-l\t\tgenerate client side stubs\n");
f_print (stderr, "-L\t\tserver errors will be printed to syslog\n");
f_print (stderr, "-m\t\tgenerate server side stubs\n");
f_print (stderr, "-M\t\tgenerate MT-safe code\n");
f_print (stderr, "-n netid\tgenerate server code that supports named netid\n");
f_print (stderr, "-N\t\tsupports multiple arguments and call-by-value\n");
f_print (stderr, "-o outfile\tname of the output file\n");
f_print (stderr, "-s nettype\tgenerate server code that supports named nettype\n");
f_print (stderr, "-Sc\t\tgenerate sample client code that uses remote procedures\n");
f_print (stderr, "-Ss\t\tgenerate sample server code that defines remote procedures\n");
f_print (stderr, "-Sm \t\tgenerate makefile template \n");
f_print (stderr, "-t\t\tgenerate RPC dispatch table\n");
f_print (stderr, "-T\t\tgenerate code to support RPC dispatch tables\n");
f_print (stderr, "-Y path\t\tdirectory name to find C preprocessor (cpp)\n");
exit (1);
}