Skip to content

Commit

Permalink
Revert "fbcode/gloo/common"
Browse files Browse the repository at this point in the history
This reverts commit 8014f79.
  • Loading branch information
c-p-i-o committed Nov 9, 2024
1 parent c9af35b commit f2a6125
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
33 changes: 33 additions & 0 deletions gloo/common/win.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

#include "gloo/common/win.h"
#include "gloo/common/logging.h"

#include <mutex>

namespace gloo {

static std::once_flag init_flag;

// The WSAStartup function must be the first Windows Sockets function
// called by an application or DLL.
// https://docs.microsoft.com/ru-ru/windows/win32/api/winsock/nf-winsock-wsastartup

void init_winsock() {
std::call_once(init_flag, []() {
WSADATA wsa_data;
int res;
res = WSAStartup(MAKEWORD(2, 2), &wsa_data);
if (res != 0) {
GLOO_ENFORCE(false, "WSAStartup failed: ", res);
}
});
}

} // namespace gloo
19 changes: 19 additions & 0 deletions gloo/common/win.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

#include <winsock2.h>

#pragma comment(lib, "Ws2_32.lib")

namespace gloo {

void init_winsock();

} // namespace gloo

0 comments on commit f2a6125

Please sign in to comment.