]> git.sesse.net Git - vlc/blobdiff - src/extras/libc.c
aout: macro-vectorize aout_ChannelsReorder()
[vlc] / src / extras / libc.c
index 69974f45e78e38e8a3fb2c1ff03541c4a4aa2bcb..3389c57d07516824d043d0aa03b23c165d50b820 100644 (file)
@@ -1,29 +1,23 @@
 /*****************************************************************************
  * libc.c: Extra libc function for some systems.
  *****************************************************************************
- * Copyright (C) 2002-2006 the VideoLAN team
- * $Id$
+ * Copyright (C) 2002-2006 VLC authors and VideoLAN
  *
- * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
- *          Samuel Hocevar <sam@zoy.org>
- *          Gildas Bazin <gbazin@videolan.org>
- *          Derk-Jan Hartman <hartman at videolan dot org>
- *          Christophe Massiot <massiot@via.ecp.fr>
- *          Rémi Denis-Courmont <rem à videolan.org>
+ * Authors: Gildas Bazin <gbazin@videolan.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 2 of the License, or
+ * 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 General Public License for more details.
+ * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #include <vlc_common.h>
 #include <vlc_charset.h>
 
-#if defined(HAVE_POSIX_MEMALIGN)
-#   include <stdlib.h>
-#elif defined(HAVE_MEMALIGN) || defined(WIN32)
-#   include <malloc.h>
-#endif
-
 #include <errno.h>
 
 #undef iconv_t
 #   include <iconv.h>
 #endif
 
+#if defined(__OS2__) && defined(__INNOTEK_LIBC__)
+#   include <uconv.h>
+
+typedef struct os2_iconv_t
+{
+    UconvObject from;
+} os2_iconv_t;
+#endif
+
 /*****************************************************************************
  * Local conversion routine from ISO_6937 to UTF-8 charset. Support for this
  * is still missing in libiconv, hence multiple operating systems lack it.
@@ -338,7 +335,42 @@ vlc_iconv_t vlc_iconv_open( const char *tocode, const char *fromcode )
         return (vlc_iconv_t)(-2);
 #endif
 #if defined(HAVE_ICONV)
+# if defined(__OS2__) && defined(__INNOTEK_LIBC__)
+    char tocode_ucs2[] = "UCS-2LE";
+    char fromcode_ucs2[] = "UCS-2LE";
+    os2_iconv_t *p_os2_iconv;
+
+    /* Workaround for UTF-16 because OS/2 supports UCS-2 only not UTF-16 */
+    if( !strncmp( tocode, "UTF-16", 6 ))
+    {
+        strncpy( tocode_ucs2 + 5, tocode + 6, 2 );
+        tocode = tocode_ucs2;
+    }
+
+    if( !strncmp( fromcode, "UTF-16", 6 ))
+    {
+        strncpy( fromcode_ucs2 + 5, fromcode + 6, 2 );
+        fromcode = fromcode_ucs2;
+    }
+
+    p_os2_iconv = ( os2_iconv_t * )iconv_open( tocode, fromcode );
+
+    if( p_os2_iconv != ( iconv_t )(-1))
+    {
+        /* Mimic a behavior of GNU libiconv */
+        uconv_attribute_t attr;
+
+        UniQueryUconvObject( p_os2_iconv->from, &attr,
+                             sizeof( uconv_attribute_t ),
+                             NULL, NULL, NULL );
+        attr.converttype |= CVTTYPE_PATH;
+        UniSetUconvObject( p_os2_iconv->from, &attr );
+    }
+
+    return ( vlc_iconv_t )p_os2_iconv;
+# else
     return iconv_open( tocode, fromcode );
+# endif
 #else
     return (vlc_iconv_t)(-1);
 #endif
@@ -425,19 +457,3 @@ bool vlc_ureduce( unsigned *pi_dst_nom, unsigned *pi_dst_den,
 
     return b_exact;
 }
-
-void *vlc_memalign(size_t align, size_t size)
-{
-    void *base;
-#if defined(HAVE_POSIX_MEMALIGN)
-    if (unlikely(posix_memalign(&base, align, size)))
-        base = NULL;
-#elif defined(HAVE_MEMALIGN)
-    base = memalign(align, size);
-#elif defined(WIN32)
-    base = __mingw_aligned_malloc(size, align);
-#else
-#   error Unimplemented!
-#endif
-    return base;
-}