Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jul 2013 08:06:26 +0000 (UTC)
From:      Peter Wemm <peter@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r252458 - head/lib/libc/iconv
Message-ID:  <201307010806.r6186QmN027318@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: peter
Date: Mon Jul  1 08:06:26 2013
New Revision: 252458
URL: http://svnweb.freebsd.org/changeset/base/252458

Log:
  __weak_alias() doesn't exist on FreeBSD.  Use __weak_reference();
  
  Expose iconv functions as weak symbols as well as their internal
  remapped #define names.  This is necessary for autoconf compatability -
  on Linux it appears that #include <iconv.h> isn't a link time
  prerequisite for their version that's built into glibc.
  
  Initialize the pthread rwlock.  Note that upstream has three
  separate locks.  The file-local static lock appears intentional.
  
  I'm using this as a ports-compatible compile-time substitute for
  converters/libiconv on one of my personal machines.

Modified:
  head/lib/libc/iconv/Symbol.map
  head/lib/libc/iconv/citrus_lock.h
  head/lib/libc/iconv/iconv.c

Modified: head/lib/libc/iconv/Symbol.map
==============================================================================
--- head/lib/libc/iconv/Symbol.map	Mon Jul  1 07:07:35 2013	(r252457)
+++ head/lib/libc/iconv/Symbol.map	Mon Jul  1 08:06:26 2013	(r252458)
@@ -17,6 +17,16 @@ FBSD_1.2 {
 	libiconvlist;
 };
 
+FBSD_1.3 {
+	iconv;
+	iconv_open;
+	iconv_close;
+	iconv_open_into;
+	iconv_set_relocation_prefix;
+	iconvctl;
+	iconvlist;
+};
+
 FBSDprivate_1.0 {
 	_citrus_bcs_convert_to_lower;
 	_citrus_bcs_convert_to_upper;

Modified: head/lib/libc/iconv/citrus_lock.h
==============================================================================
--- head/lib/libc/iconv/citrus_lock.h	Mon Jul  1 07:07:35 2013	(r252457)
+++ head/lib/libc/iconv/citrus_lock.h	Mon Jul  1 08:06:26 2013	(r252458)
@@ -27,7 +27,8 @@
 
 #include <pthread.h>
 
-static pthread_rwlock_t	lock;
+/* XXX Yes, the original code has three separate file-local lock instances */
+static pthread_rwlock_t	lock = PTHREAD_RWLOCK_INITIALIZER;
 
 #define WLOCK	if (__isthreaded)		\
 		    pthread_rwlock_wrlock(&lock);

Modified: head/lib/libc/iconv/iconv.c
==============================================================================
--- head/lib/libc/iconv/iconv.c	Mon Jul  1 07:07:35 2013	(r252457)
+++ head/lib/libc/iconv/iconv.c	Mon Jul  1 08:06:26 2013	(r252458)
@@ -47,16 +47,13 @@
 #include "citrus_hash.h"
 #include "citrus_iconv.h"
 
-#ifdef __weak_alias
-__weak_alias(libiconv, _iconv)
-__weak_alias(libiconv_open, _iconv_open)
-__weak_alias(libiconv_open_into, _iconv_open_into)
-__weak_alias(libiconv_close, _iconv_close)
-__weak_alias(libiconvlist, _iconvlist)
-__weak_alias(libiconvctl, _iconvctl)
-__weak_alias(libiconv_set_relocation_prefix, _iconv_set_relocation_prefix)
-__weak_alias(iconv_canonicalize, _iconv_canonicalize)
-#endif
+__weak_reference(libiconv, iconv);
+__weak_reference(libiconv_open, iconv_open);
+__weak_reference(libiconv_open_into, iconv_open_into);
+__weak_reference(libiconv_close, iconv_close);
+__weak_reference(libiconvlist, iconvlist);
+__weak_reference(libiconvctl, iconvctl);
+__weak_reference(libiconv_set_relocation_prefix, iconv_set_relocation_prefix);
 
 #define ISBADF(_h_)	(!(_h_) || (_h_) == (iconv_t)-1)
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307010806.r6186QmN027318>