< prev index next >

src/os/windows/vm/os_windows.cpp

Print this page




1879     // C runtime error that has no corresponding DOS error code
1880     const char* s = strerror(errno);
1881     size_t n = strlen(s);
1882     if (n >= len) n = len - 1;
1883     strncpy(buf, s, n);
1884     buf[n] = '\0';
1885     return n;
1886   }
1887 
1888   return 0;
1889 }
1890 
1891 int os::get_last_error() {
1892   DWORD error = GetLastError();
1893   if (error == 0) {
1894     error = errno;
1895   }
1896   return (int)error;
1897 }
1898 
1899 Semaphore::Semaphore(uint value, uint max) {
1900   _semaphore = ::CreateSemaphore(NULL, value, max, NULL);
1901 
1902   assert(_semaphore != NULL, err_msg("CreateSemaphore failed: %ld", GetLastError()));
1903 }
1904 
1905 Semaphore::~Semaphore() {
1906   if (_semaphore != NULL) {
1907     ::CloseHandle(_semaphore);
1908   }
1909 }
1910 
1911 void Semaphore::signal(uint count) {
1912   BOOL ret = ::ReleaseSemaphore(_semaphore, count, NULL);
1913 
1914   assert(ret != 0, err_msg("ReleaseSemaphore failed: %d", GetLastError()));
1915 }
1916 
1917 void Semaphore::signal() {
1918   signal(1);
1919 }
1920 




1879     // C runtime error that has no corresponding DOS error code
1880     const char* s = strerror(errno);
1881     size_t n = strlen(s);
1882     if (n >= len) n = len - 1;
1883     strncpy(buf, s, n);
1884     buf[n] = '\0';
1885     return n;
1886   }
1887 
1888   return 0;
1889 }
1890 
1891 int os::get_last_error() {
1892   DWORD error = GetLastError();
1893   if (error == 0) {
1894     error = errno;
1895   }
1896   return (int)error;
1897 }
1898 
1899 Semaphore::Semaphore(uint value) {
1900   _semaphore = ::CreateSemaphore(NULL, value, LONG_MAX, NULL);
1901 
1902   assert(_semaphore != NULL, err_msg("CreateSemaphore failed: %ld", GetLastError()));
1903 }
1904 
1905 Semaphore::~Semaphore() {
1906   if (_semaphore != NULL) {
1907     ::CloseHandle(_semaphore);
1908   }
1909 }
1910 
1911 void Semaphore::signal(uint count) {
1912   BOOL ret = ::ReleaseSemaphore(_semaphore, count, NULL);
1913 
1914   assert(ret != 0, err_msg("ReleaseSemaphore failed: %d", GetLastError()));
1915 }
1916 
1917 void Semaphore::signal() {
1918   signal(1);
1919 }
1920 


< prev index next >