[Libreoffice-commits] .: 3 commits - sal/osl
Michael Meeks
michael at kemper.freedesktop.org
Mon Nov 21 09:09:49 PST 2011
sal/osl/unx/backtrace.c | 81 -----------------------------------------
sal/osl/unx/backtrace.h | 23 +----------
sal/osl/unx/socket.c | 23 ++++-------
sal/osl/unx/system.c | 94 ------------------------------------------------
sal/osl/unx/system.h | 4 --
5 files changed, 11 insertions(+), 214 deletions(-)
New commits:
commit 513c888595db021c8eaed77a2438301b1c306885
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date: Fri Nov 18 19:57:16 2011 +0100
Remove internal backtrace and backtrace_symbols_fd
diff --git a/sal/osl/unx/backtrace.c b/sal/osl/unx/backtrace.c
index d5e4e94..01ff18f 100644
--- a/sal/osl/unx/backtrace.c
+++ b/sal/osl/unx/backtrace.c
@@ -211,87 +211,6 @@ void backtrace_symbols_fd( void **buffer, int size, int fd )
#define _GNU_SOURCE
#endif
-#include <dlfcn.h>
-#include <pthread.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include "backtrace.h"
-
-#if defined(SPARC)
-
-#define FRAME_PTR_OFFSET 1
-#define FRAME_OFFSET 0
-
-#else
-
-#error Unknown Linux target platform.
-
-#endif /* defined SPARC or INTEL */
-
-typedef int ptrdiff_t;
-
-int backtrace( void **buffer, int max_frames )
-{
- struct frame *fp;
- jmp_buf ctx;
- int i;
-
- /* flush register windows */
-#ifdef SPARC
- asm("ta 3");
-#endif
- /* get stack- and framepointer */
- setjmp(ctx);
- fp = (struct frame*)(((size_t*)(ctx))[FRAME_PTR_OFFSET]);
- for ( i=0; (i<FRAME_OFFSET) && (fp!=0); i++)
- fp = fp->fr_savfp;
-
- /* iterate through backtrace */
- for (i=0; fp && fp->fr_savpc && i<max_frames; i++)
- {
- /* store frame */
- *(buffer++) = (void *)fp->fr_savpc;
- /* next frame */
- fp=fp->fr_savfp;
- }
- return i;
-}
-
-void backtrace_symbols_fd( void **buffer, int size, int fd )
-{
- FILE *fp = fdopen( fd, "w" );
-
- if ( fp )
- {
- void **pFramePtr;
-
- for ( pFramePtr = buffer; size > 0 && pFramePtr && *pFramePtr; pFramePtr++, size-- )
- {
- Dl_info dli;
-
- if ( 0 != dladdr( *pFramePtr, &dli ) )
- {
- ptrdiff_t offset;
-
- if ( dli.dli_fname && dli.dli_fbase )
- {
- offset = (ptrdiff_t)*pFramePtr - (ptrdiff_t)dli.dli_fbase;
- fprintf( fp, "%s+0x%x", dli.dli_fname, offset );
- }
- if ( dli.dli_sname && dli.dli_saddr )
- {
- offset = (ptrdiff_t)*pFramePtr - (ptrdiff_t)dli.dli_saddr;
- fprintf( fp, "(%s+0x%x)", dli.dli_sname, offset );
- }
- }
- fprintf( fp, "[0x%x]\n", *pFramePtr );
- }
-
- fflush( fp );
- fclose( fp );
- }
-}
-
#endif /* defined LINUX */
#if defined( MACOSX )
diff --git a/sal/osl/unx/backtrace.h b/sal/osl/unx/backtrace.h
index 79fb580..61d63ec 100644
--- a/sal/osl/unx/backtrace.h
+++ b/sal/osl/unx/backtrace.h
@@ -58,27 +58,8 @@ struct frame {
#endif /* defined SOLARIS || FREEBSD || NETBSD || OPENBSD */
-#if defined (LINUX) && defined (SPARC)
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* backtrace function with same behaviour as defined in GNU libc */
-
-int backtrace( void **buffer, int max_frames );
-
-void backtrace_symbols_fd( void **buffer, int size, int fd );
-
-/* no frame.h on linux sparc */
-struct frame {
- long arg0[8];
- long arg1[6];
- struct frame *fr_savfp;
- long fr_savpc;
-};
-
-#ifdef __cplusplus
-} /* extern "C" */
+#if defined (LINUX)
+#include <execinfo.h>
#endif
#endif /* defined LINUX && SPARC */
commit af19d9f563667376f759b4526bc1bcb056947394
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date: Fri Nov 18 19:54:28 2011 +0100
Remove internal gethostbyname_r implementation.
diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c
index 4bb0e46..63d67bc 100644
--- a/sal/osl/unx/system.c
+++ b/sal/osl/unx/system.c
@@ -32,100 +32,6 @@
static pthread_mutex_t getrtl_mutex = PTHREAD_MUTEX_INITIALIZER;
-/* struct passwd differs on some platforms */
-#if !defined(FREEBSD) || (__FreeBSD_version < 601103)
-
-extern int h_errno;
-
-struct hostent *gethostbyname_r(const char *name, struct hostent *result,
- char *buffer, int buflen, int *h_errnop)
-{
- /* buffer layout: name\0
- * array_of_pointer_to_aliases
- * NULL
- * alias1\0...aliasn\0
- * array_of_pointer_to_addresses
- * NULL
- * addr1addr2addr3...addrn
- */
- struct hostent* res;
-
- pthread_mutex_lock(&getrtl_mutex);
-
- if ( (res = gethostbyname(name)) )
- {
- int nname, naliases, naddr_list, naliasesdata, n;
- char **p, **parray, *data;
-
- /* Check buffer size before copying, we want to leave the
- * buffers unmodified in case something goes wrong.
- *
- * Is this required?
- */
-
- nname= strlen(res->h_name)+1;
-
- naliases = naddr_list = naliasesdata = 0;
-
- for ( p = res->h_aliases; *p != NULL; p++) {
- naliases++;
- naliasesdata += strlen(*p)+1;
- }
-
- for ( p = res->h_addr_list; *p != NULL; p++)
- naddr_list++;
-
- if ( nname
- + (naliases+1)*sizeof(char*) + naliasesdata
- + (naddr_list+1)*sizeof(char*) + naddr_list*res->h_length
- <= buflen )
- {
- memcpy(result, res, sizeof(struct hostent));
-
- strcpy(buffer, res->h_name);
- result->h_name = buffer;
- buffer += nname;
-
- parray = (char**)buffer;
- result->h_aliases = parray;
- data = buffer + (naliases+1)*sizeof(char*);
- for ( p = res->h_aliases; *p != NULL; p++) {
- n = strlen(*p)+1;
- *parray++ = data;
- memcpy(data, *p, n);
- data += n;
- }
- *parray = NULL;
- buffer = data;
- parray = (char**)buffer;
- result->h_addr_list = parray;
- data = buffer + (naddr_list+1)*sizeof(char*);
- for ( p = res->h_addr_list; *p != NULL; p++) {
- *parray++ = data;
- memcpy(data, *p, res->h_length);
- data += res->h_length;
- }
- *parray = NULL;
-
- res = result;
- }
- else
- {
- errno = ERANGE;
- res = NULL;
- }
- }
- else
- {
- *h_errnop = h_errno;
- }
-
- pthread_mutex_unlock(&getrtl_mutex);
-
- return res;
-}
-#endif /* !defined(FREEBSD) || (__FreeBSD_version < 601103) */
-
#if defined(MACOSX)
/*
* Add support for resolving Mac native alias files (not the same as unix alias files)
diff --git a/sal/osl/unx/system.h b/sal/osl/unx/system.h
index c8f4871..d3293ad 100644
--- a/sal/osl/unx/system.h
+++ b/sal/osl/unx/system.h
@@ -504,10 +504,6 @@ extern struct spwd *getspnam_r(const char *name, struct spwd *result,
struct tm *localtime_r(const time_t *timep, struct tm *buffer);
struct tm *gmtime_r(const time_t *timep, struct tm *buffer);
#endif /* !defined FREEBSD || (__FreeBSD_version < 500112) */
-#if !defined(FREEBSD) || (__FreeBSD_version < 601103)
-struct hostent *gethostbyname_r(const char *name, struct hostent *result,
- char *buffer, int buflen, int *h_errnop);
-#endif /* !defined(FREEBSD) || (__FreeBSD_version < 601103) */
#endif
#endif /* __OSL_SYSTEM_H__ */
commit 161ff9a4430472eaffbb438d25b5c6b5824c50fd
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date: Fri Nov 18 19:52:45 2011 +0100
Replace gethostbyname by _osl_gethostbyname_r in socket.c .
diff --git a/sal/osl/unx/socket.c b/sal/osl/unx/socket.c
index ed31a82..d471463 100644
--- a/sal/osl/unx/socket.c
+++ b/sal/osl/unx/socket.c
@@ -1014,22 +1014,17 @@ oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *ustrHostname)
oslHostAddr SAL_CALL osl_psz_createHostAddrByName (const sal_Char *pszHostname)
{
- struct hostent *he;
- oslHostAddr addr;
+ struct hostent aHe;
+ struct hostent *pHe;
+ sal_Char heBuffer[ MAX_HOSTBUFFER_SIZE ];
+ int nErrorNo;
- static oslMutex mutex = NULL;
+ pHe = _osl_gethostbyname_r (
+ pszHostname,
+ &aHe, heBuffer,
+ sizeof(heBuffer), &nErrorNo );
- if (mutex == NULL)
- mutex = osl_createMutex();
-
- osl_acquireMutex(mutex);
-
- he = gethostbyname((sal_Char *)pszHostname);
- addr = _osl_hostentToHostAddr (he);
-
- osl_releaseMutex(mutex);
-
- return addr;
+ return _osl_hostentToHostAddr (pHe);
}
/*****************************************************************************/
More information about the Libreoffice-commits
mailing list