mingw_functions.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /** **************************************************************************
  2. * mingw_functions.c
  3. *
  4. * Copyright 2008 Bryan Ischo <[email protected]>
  5. *
  6. * This file is part of libs3.
  7. *
  8. * libs3 is free software: you can redistribute it and/or modify it under the
  9. * terms of the GNU Lesser General Public License as published by the Free
  10. * Software Foundation, version 3 or above of the License. You can also
  11. * redistribute and/or modify it under the terms of the GNU General Public
  12. * License, version 2 or above of the License.
  13. *
  14. * In addition, as a special exception, the copyright holders give
  15. * permission to link the code of this library and its programs with the
  16. * OpenSSL library, and distribute linked combinations including the two.
  17. *
  18. * libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
  19. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  20. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  21. * details.
  22. *
  23. * You should have received a copy of the GNU Lesser General Public License
  24. * version 3 along with libs3, in a file named COPYING. If not, see
  25. * <http://www.gnu.org/licenses/>.
  26. *
  27. * You should also have received a copy of the GNU General Public License
  28. * version 2 along with libs3, in a file named COPYING-GPLv2. If not, see
  29. * <http://www.gnu.org/licenses/>.
  30. *
  31. ************************************************************************** **/
  32. #include <pthread.h>
  33. #include <sys/utsname.h>
  34. unsigned long pthread_self()
  35. {
  36. return (unsigned long) GetCurrentThreadId();
  37. }
  38. int pthread_mutex_init(pthread_mutex_t *mutex, void *v)
  39. {
  40. (void) v;
  41. InitializeCriticalSection(&(mutex->criticalSection));
  42. return 0;
  43. }
  44. int pthread_mutex_lock(pthread_mutex_t *mutex)
  45. {
  46. EnterCriticalSection(&(mutex->criticalSection));
  47. return 0;
  48. }
  49. int pthread_mutex_unlock(pthread_mutex_t *mutex)
  50. {
  51. LeaveCriticalSection(&(mutex->criticalSection));
  52. return 0;
  53. }
  54. int pthread_mutex_destroy(pthread_mutex_t *mutex)
  55. {
  56. DeleteCriticalSection(&(mutex->criticalSection));
  57. return 0;
  58. }
  59. int uname(struct utsname *u)
  60. {
  61. OSVERSIONINFO info;
  62. info.dwOSVersionInfoSize = sizeof(info);
  63. if (!GetVersionEx(&info)) {
  64. return -1;
  65. }
  66. u->machine = "";
  67. switch (info.dwMajorVersion) {
  68. case 4:
  69. switch (info.dwMinorVersion) {
  70. case 0:
  71. u->sysname = "Microsoft Windows NT 4.0";
  72. break;
  73. case 10:
  74. u->sysname = "Microsoft Windows 98";
  75. break;
  76. case 90:
  77. u->sysname = "Microsoft Windows Me";
  78. break;
  79. default:
  80. return -1;
  81. }
  82. break;
  83. case 5:
  84. switch (info.dwMinorVersion) {
  85. case 0:
  86. u->sysname = "Microsoft Windows 2000";
  87. break;
  88. case 1:
  89. u->sysname = "Microsoft Windows XP";
  90. break;
  91. case 2:
  92. u->sysname = "Microsoft Server 2003";
  93. break;
  94. default:
  95. return -1;
  96. }
  97. break;
  98. default:
  99. return -1;
  100. }
  101. return 0;
  102. }