]> git.sesse.net Git - vlc/commitdiff
WinCE: add replacement getpid() function
authorPierre Ynard <linkfanel@yahoo.fr>
Thu, 27 Aug 2009 09:14:10 +0000 (11:14 +0200)
committerPierre Ynard <linkfanel@yahoo.fr>
Thu, 27 Aug 2009 09:14:10 +0000 (11:14 +0200)
And remove #ifdefs from code

compat/getpid.c [new file with mode: 0644]
configure.ac
include/vlc_fixups.h
src/config/file.c
src/modules/cache.c

diff --git a/compat/getpid.c b/compat/getpid.c
new file mode 100644 (file)
index 0000000..e5d9315
--- /dev/null
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * getpid.c: POSIX getpid() replacement
+ *****************************************************************************
+ * Copyright © 2009 the VideoLAN project
+ *
+ * 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
+ * (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.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#ifdef WIN32
+# include <windows.h>
+#endif
+
+pid_t getpid (void)
+{
+#ifdef WIN32
+    return (pid_t) GetCurrentProcessId ();
+#else
+# error Unimplemented!
+#endif
+}
index 2a30a6bcc96f42d7b8bb475c7c14160e1e07a127..ccfa3303f990b41183cb6223607451c7a6db8ad8 100644 (file)
@@ -564,7 +564,7 @@ dnl Check for usual libc functions
 AC_CHECK_FUNCS([gettimeofday isatty sigrelse getpwuid_r memalign posix_memalign if_nametoindex getenv putenv setenv ctime_r daemon fork lstat posix_fadvise posix_madvise uselocale])
 AC_FUNC_ALLOCA
 AC_CHECK_FUNCS(fcntl)
-AC_REPLACE_FUNCS([asprintf atof atoll getcwd gmtime_r lldiv localtime_r rewind strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtoll vasprintf swab])
+AC_REPLACE_FUNCS([asprintf atof atoll getcwd getpid gmtime_r lldiv localtime_r rewind strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtoll vasprintf swab])
 AC_CHECK_FUNCS([stricmp strnicmp])
 AC_CHECK_FUNCS(fdatasync,,
   [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
index 74cf4544a5ab5d104e99eae9791fdce025344c91..24d3069a783f76e745a6140ee69fc3e1ab96955c 100644 (file)
@@ -53,6 +53,10 @@ typedef struct
 # include <stdarg.h> /* va_list */
 #endif
 
+#ifndef HAVE_GETPID
+# include <sys/types.h> /* pid_t */
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -133,6 +137,10 @@ void rewind (FILE *);
 char *getcwd (char *buf, size_t size);
 #endif
 
+#ifndef HAVE_GETPID
+pid_t getpid (void);
+#endif
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
index 1da0a698abd2fc4601069e1faee2db51a5beda5b..6c8340ee8939a34a1c8427b9752275185d75fd64 100644 (file)
@@ -522,13 +522,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
         goto error;
     }
 
-    if (asprintf (&temporary, "%s.%u", permanent,
-#ifdef UNDER_CE
-                  GetCurrentProcessId ()
-#else
-                  getpid ()
-#endif
-                 ) == -1)
+    if (asprintf (&temporary, "%s.%u", permanent, getpid ()) == -1)
     {
         temporary = NULL;
         module_list_free (list);
index 0f2f5ceceac823e8f2bea603cfca619e70bbd596..dba50d52a44c412ac91104390c1e915f90d9b18f 100644 (file)
@@ -508,12 +508,7 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
 
     char psz_tmpname[sizeof (psz_filename) + 12];
     snprintf (psz_tmpname, sizeof (psz_tmpname), "%s.%"PRIu32, psz_filename,
-#ifdef UNDER_CE
-              (uint32_t)GetCurrentProcessId ()
-#else
-              (uint32_t)getpid ()
-#endif
-             );
+              (uint32_t)getpid ());
     file = utf8_fopen( psz_tmpname, "wb" );
     if (file == NULL)
         goto error;