Diff
Not logged in

Differences From Artifact [87f49ca500]:

To Artifact [8fbb1d5e0c]:


103
104
105
106
107
108
109
110
111


112
113
114


115
116
117
118
119
120
121
103
104
105
106
107
108
109


110
111
112


113
114
115
116
117
118
119
120
121







-
-
+
+

-
-
+
+







#endif

#if !defined(HAVE_GETPWNAM_R_5) && !defined(HAVE_GETPWNAM_R_4)
#define NEED_COPYPWD 1
static int		CopyPwd(struct passwd *tgtPtr, char *buf, int buflen);
#endif

static int		CopyArray(char **src, int elsize, char *buf,
			    int buflen);
static size_t	CopyArray(char **src, int elsize, char *buf,
			    size_t buflen);
static int		CopyHostent(struct hostent *tgtPtr, char *buf,
			    int buflen);
static int		CopyString(const char *src, char *buf, int buflen);
			    size_t buflen);
static size_t	CopyString(const char *src, char *buf, size_t buflen);

#endif

#ifdef NEED_PW_CLEANER
static void		FreePwBuf(void *dummy);
#endif
#ifdef NEED_GR_CLEANER
750
751
752
753
754
755
756
757

758
759
760

761
762
763
764
765
766
767
750
751
752
753
754
755
756

757
758
759

760
761
762
763
764
765
766
767







-
+


-
+







#define NEED_COPYSTRING 1
#define NEED_COPYARRAY 1

static int
CopyHostent(
    struct hostent *tgtPtr,
    char *buf,
    int buflen)
    size_t buflen)
{
    char *p = buf;
    int copied, len = 0;
    Tcl_Size copied, len = 0;

    copied = CopyString(tgtPtr->h_name, p, buflen - len);
    if (copied == -1) {
	goto range;
    }
    tgtPtr->h_name = (copied > 0) ? p : NULL;
    len += copied;
871
872
873
874
875
876
877
878

879
880
881
882
883
884
885

886
887

888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908

909
910
911
912
913
914
915
871
872
873
874
875
876
877

878
879
880
881
882
883
884

885
886

887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907

908
909
910
911
912
913
914
915







-
+






-
+

-
+




















-
+







 * Side effects:
 *      None.
 *
 *---------------------------------------------------------------------------
 */

#ifdef NEED_COPYARRAY
static int
static size_t
CopyArray(
    char **src,			/* Array of elements to copy. */
    int elsize,			/* Size of each element, or -1 to indicate
				 * that they are C strings of dynamic
				 * length. */
    char *buf,			/* Buffer to copy into. */
    int buflen)			/* Size of buffer. */
    size_t buflen)			/* Size of buffer. */
{
    int i, j, len = 0;
    size_t i, j, len = 0;
    char *p, **newBuffer;

    if (src == NULL) {
	return 0;
    }

    for (i = 0; src[i] != NULL; i++) {
	/*
	 * Empty loop to count how many.
	 */
    }
    len = sizeof(char *) * (i + 1);	/* Leave place for the array. */
    if (len >  buflen) {
	return -1;
    }

    newBuffer = (char **)buf;
    p = buf + len;

    for (j = 0; j < i; j++) {
	int sz = (elsize<0 ? (int) strlen(src[j]) + 1 : elsize);
	size_t sz = (elsize<0 ? strlen(src[j]) + 1 : (size_t)elsize);

	len += sz;
	if (len > buflen) {
	    return -1;
	}
	memcpy(p, src[j], sz);
	newBuffer[j] = p;
935
936
937
938
939
940
941
942

943
944
945
946

947
948

949
950
951
952
953
954
955
935
936
937
938
939
940
941

942
943
944
945

946
947

948
949
950
951
952
953
954
955







-
+



-
+

-
+







 * Side effects:
 *      None
 *
 *---------------------------------------------------------------------------
 */

#ifdef NEED_COPYSTRING
static int
static size_t
CopyString(
    const char *src,		/* String to copy. */
    char *buf,			/* Buffer to copy into. */
    int buflen)			/* Size of buffer. */
    size_t buflen)			/* Size of buffer. */
{
    int len = 0;
    size_t len = 0;

    if (src != NULL) {
	len = strlen(src) + 1;
	if (len > buflen) {
	    return -1;
	}
	memcpy(buf, src, len);
982
983
984
985
986
987
988
989
990


991
992
993
994
995
996
997
982
983
984
985
986
987
988


989
990
991
992
993
994
995
996
997







-
-
+
+







 *	instruction in the four integers designated by 'regsPtr'
 *
 *----------------------------------------------------------------------
 */

int
TclWinCPUID(
    int index,		/* Which CPUID value to retrieve. */
    int *regsPtr)	/* Registers after the CPUID. */
    int index,			/* Which CPUID value to retrieve. */
    int *regsPtr)		/* Registers after the CPUID. */
{
    int status = TCL_ERROR;

    /* See: <http://en.wikipedia.org/wiki/CPUID> */
#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
    __asm__ __volatile__("movq %%rbx, %%rsi     \n\t" /* save %rbx */
	    "cpuid            \n\t"