re PR libfortran/23803 ([mingw32] getlog malfunction)
PR libfortran/23803 * intrinsics/getXid.c: Add getpid wrapper for MinGW. * intrinsics/getlog.c: Add getlogin wrapper for MinGW. * intrinsics/hostnm.c: Add gethostname wrapper for MinGW. Co-Authored-By: Danny Smith <dannysmith@users.sourceforge.net> From-SVN: r104624
This commit is contained in:
parent
ad90e28f8f
commit
86ab632081
@ -1,3 +1,11 @@
|
|||||||
|
2005-09-25 Francois-Xavier Coudert <coudert@clipper.ens.fr>
|
||||||
|
Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
|
||||||
|
PR libfortran/23803
|
||||||
|
* intrinsics/getXid.c: Add getpid wrapper for MinGW.
|
||||||
|
* intrinsics/getlog.c: Add getlogin wrapper for MinGW.
|
||||||
|
* intrinsics/hostnm.c: Add gethostname wrapper for MinGW.
|
||||||
|
|
||||||
2005-09-24 Francois-Xavier Coudert <coudert@clipper.ens.fr>
|
2005-09-24 Francois-Xavier Coudert <coudert@clipper.ens.fr>
|
||||||
|
|
||||||
PR libfortran/23802
|
PR libfortran/23802
|
||||||
|
@ -38,6 +38,11 @@ Boston, MA 02110-1301, USA. */
|
|||||||
|
|
||||||
#include "libgfortran.h"
|
#include "libgfortran.h"
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#define HAVE_GETPID
|
||||||
|
#include <process.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_GETGID
|
#ifdef HAVE_GETGID
|
||||||
extern GFC_INTEGER_4 PREFIX(getgid) (void);
|
extern GFC_INTEGER_4 PREFIX(getgid) (void);
|
||||||
export_proto_np(PREFIX(getgid));
|
export_proto_np(PREFIX(getgid));
|
||||||
|
@ -39,6 +39,29 @@ Boston, MA 02110-1301, USA. */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Windows32 version */
|
||||||
|
#if defined __MINGW32__ && !defined HAVE_GETLOGIN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <lmcons.h> /* for UNLEN */
|
||||||
|
|
||||||
|
static char *
|
||||||
|
w32_getlogin (void)
|
||||||
|
{
|
||||||
|
static char name [UNLEN + 1];
|
||||||
|
DWORD namelen = sizeof (name);
|
||||||
|
|
||||||
|
GetUserName (name, &namelen);
|
||||||
|
return (name[0] == 0 ? NULL : name);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef getlogin
|
||||||
|
#define getlogin w32_getlogin
|
||||||
|
#define HAVE_GETLOGIN 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* GETLOG (LOGIN), g77 intrinsic for retrieving the login name for the
|
/* GETLOG (LOGIN), g77 intrinsic for retrieving the login name for the
|
||||||
process.
|
process.
|
||||||
CHARACTER(len=*), INTENT(OUT) :: LOGIN */
|
CHARACTER(len=*), INTENT(OUT) :: LOGIN */
|
||||||
|
@ -38,7 +38,47 @@ Boston, MA 02110-1301, USA. */
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../io/io.h"
|
|
||||||
|
/* Windows32 version */
|
||||||
|
#if defined __MINGW32__ && !defined HAVE_GETHOSTNAME
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
w32_gethostname (char *name, size_t len)
|
||||||
|
{
|
||||||
|
/* We could try the WinSock API gethostname, but that will
|
||||||
|
fail if WSAStartup function has has not been called. We don't
|
||||||
|
really need a name that will be understood by socket API, so avoid
|
||||||
|
unnecessary dependence on WinSock libraries by using
|
||||||
|
GetComputerName instead. */
|
||||||
|
|
||||||
|
/* On Win9x GetComputerName fails if the input size is less
|
||||||
|
than MAX_COMPUTERNAME_LENGTH + 1. */
|
||||||
|
char buffer[MAX_COMPUTERNAME_LENGTH + 1];
|
||||||
|
DWORD size = sizeof (buffer);
|
||||||
|
|
||||||
|
if (!GetComputerName (buffer, &size))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ((size = strlen (buffer) + 1) > len)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
/* Truncate as per POSIX spec. We do not NUL-terminate. */
|
||||||
|
size = len;
|
||||||
|
}
|
||||||
|
memcpy (name, buffer, (size_t) size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef gethostname
|
||||||
|
#define gethostname w32_gethostname
|
||||||
|
#define HAVE_GETHOSTNAME 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* SUBROUTINE HOSTNM(NAME, STATUS)
|
/* SUBROUTINE HOSTNM(NAME, STATUS)
|
||||||
CHARACTER(len=*), INTENT(OUT) :: NAME
|
CHARACTER(len=*), INTENT(OUT) :: NAME
|
||||||
|
Loading…
Reference in New Issue
Block a user