1/*
2 * Copyright 2016-present Facebook, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <fcntl.h>
20
21#ifdef _WIN32
22#include <sys/types.h>
23
24#include <folly/portability/Windows.h>
25
26// I have no idea what the normal values for these are,
27// and really don't care what they are. They're only used
28// within fcntl, so it's not an issue.
29#define FD_CLOEXEC HANDLE_FLAG_INHERIT
30#define O_NONBLOCK 1
31#define O_CLOEXEC _O_NOINHERIT
32#define F_GETFD 1
33#define F_SETFD 2
34#define F_GETFL 3
35#define F_SETFL 4
36
37#ifdef HAVE_POSIX_FALLOCATE
38#undef HAVE_POSIX_FALLOCATE
39#endif
40#define HAVE_POSIX_FALLOCATE 1
41
42// See portability/Unistd.h for why these need to be in a namespace
43// rather then extern "C".
44namespace folly {
45namespace portability {
46namespace fcntl {
47int creat(char const* fn, int pm);
48int fcntl(int fd, int cmd, ...);
49int posix_fallocate(int fd, off_t offset, off_t len);
50int open(char const* fn, int of, int pm = 0);
51} // namespace fcntl
52} // namespace portability
53} // namespace folly
54
55/* using override */ using namespace folly::portability::fcntl;
56#endif
57