SQLite

Check-in [3aa8befedf]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Windows implementation of the thread-specific data interface. (CVS 2864)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3aa8befedf4534cd100a7309997a4ad2ba08af20
User & Date: drh 2006-01-06 00:36:01.000
Context
2006-01-06
01:42
Formatting changes in btree.c. (CVS 2865) (check-in: f1922da2d2 user: drh tags: trunk)
00:36
Windows implementation of the thread-specific data interface. (CVS 2864) (check-in: 3aa8befedf user: drh tags: trunk)
2006-01-05
23:42
Disable the update hook for the truncation optimization used by DELETE. (CVS 2863) (check-in: 448b3b9ded user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677

1678
1679
1680
1681
1682

1683
1684
1685
1686
1687
1688
1689
1690
        return 0;
      }
      keyInit = 1;
    }
    sqlite3Os.xLeaveMutex();
  }

  pTsd = (SqliteTsd *)pthread_getspecific(key);
  if( !pTsd ){
    pTsd = sqlite3Os.xMalloc(sizeof(SqliteTsd));
    if( pTsd ){
      memset(pTsd, 0, sizeof(SqliteTsd));
      pthread_setspecific(key, pTsd);
    }
  }
  return pTsd;
#else
  static char tsd[sizeof(SqliteTsd)];
  static int isInit = 0;

  assert( nByte==sizeof(SqliteTsd) );
  if( !isInit ){
    memset(tsd, 0, sizeof(SqliteTsd));
    isInit = 1;
  }

  return (void *)tsd;
#endif
}

/*
** The following variable, if set to a non-zero value, becomes the result
** returned from sqlite3Os.xCurrentTime().  This is used for testing.
*/







|

|

|





<
|
>
|
|
|
<
|
>
|







1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675

1676
1677
1678
1679
1680

1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
        return 0;
      }
      keyInit = 1;
    }
    sqlite3Os.xLeaveMutex();
  }

  pTsd = pthread_getspecific(key);
  if( !pTsd ){
    pTsd = sqlite3Os.xMalloc(nByte);
    if( pTsd ){
      memset(pTsd, 0, nByte);
      pthread_setspecific(key, pTsd);
    }
  }
  return pTsd;
#else

  static void *pTsd = 0;
  if( !pTsd ){
    pTsd = sqlite3Os.xMalloc(nByte);
    if( pTsd ){
      memset(pTsd, 0, nByte);

    }
  }
  return pTsd;
#endif
}

/*
** The following variable, if set to a non-zero value, becomes the result
** returned from sqlite3Os.xCurrentTime().  This is used for testing.
*/
Changes to src/os_win.c.
1027
1028
1029
1030
1031
1032
1033
1034
1035



1036


1037
1038
1039
1040

1041
1042
1043






1044
1045










1046
1047
1048
1049
1050
1051
1052
1053
  if( sqlite3_current_time ){
    *prNow = sqlite3_current_time/86400.0 + 2440587.5;
  }
#endif
  return 0;
}


/*



** Todo: This is a place-holder only


*/
static void *winThreadSpecificData(int nByte){
  static char tsd[sizeof(SqliteTsd)];
  static isInit = 0;

  assert( nByte==sizeof(SqliteTsd) );
  if( !isInit ){
    memset(tsd, 0, sizeof(SqliteTsd));






    isInit = 1;
  }










  return (void *)tsd;
}

/* Macro used to comment out routines that do not exists when there is
** no disk I/O
*/
#ifdef SQLITE_OMIT_DISKIO
# define IF_DISKIO(X)  0







<
|
>
>
>
|
>
>


|
|
>
|
|
|
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
|







1027
1028
1029
1030
1031
1032
1033

1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
  if( sqlite3_current_time ){
    *prNow = sqlite3_current_time/86400.0 + 2440587.5;
  }
#endif
  return 0;
}


/* 
** The first time this function is called from a specific thread, nByte 
** bytes of data area are allocated and zeroed. A pointer to the new 
** allocation is returned to the caller. 
**
** Each subsequent call to this function from the thread returns the same
** pointer. The argument is ignored in this case.
*/
static void *winThreadSpecificData(int nByte){
  static void *pTsd = 0;
  static int key;
  static int keyInit = 0;

  if( !keyInit ){
    sqlite3Os.xEnterMutex();
    if( !keyInit ){
      key = TlsAlloc();
      if( key==0xffffffff ){
        sqlite3Os.xLeaveMutex();
        return 0;
      }
      keyInit = 1;
    }
    sqlite3Os.xLeaveMutex();
  }
  pTsd = TlsGetValue(key);
  if( !pTsd ){
    pTsd = sqlite3Os.xMalloc(nByte);
    if( pTsd ){
      memset(pTsd, 0, nByte);
      TlsSetValue(key, pTsd);
    }
  }
  return pTsd;
}

/* Macro used to comment out routines that do not exists when there is
** no disk I/O
*/
#ifdef SQLITE_OMIT_DISKIO
# define IF_DISKIO(X)  0