<commit_before>/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <folly/experimental/io/SimpleAsyncIO.h>
#include <folly/String.h>
#if __has_include(<folly/experimental/io/AsyncIO.h>)
#define AIO_SUPPORTED
#include <folly/experimental/io/AsyncIO.h>
#endif
#if __has_include(<folly/experimental/io/IoUring.h>)
#define IOURING_SUPPORTED
#include <folly/experimental/io/IoUring.h>
#endif

#if !defined(AIO_SUPPORTED) && !defined(IOURING_SUPORTED)
#error "Cannot build without at least one of AsyncIO.h and IoUring.h"
#endif

#include <folly/portability/Sockets.h>

namespace folly {

SimpleAsyncIO::SimpleAsyncIO(Config cfg)
    : maxRequests_(cfg.maxRequests_),
      completionExecutor_(cfg.completionExecutor_),
      terminating_(false) {
#if !defined(AIO_SUPPORTED)
  if (cfg.mode_ == AIO) {
    LOG(WARNING)
        << "aio mode requested but not available at link time, falling back to io_uring.";
    cfg.setMode(IOURING);
  }
#endif
#if !defined(IOURING_SUPPORTED)
  if (cfg.mode_ == IOURING) {
    LOG(WARNING)
        << "io_uring mode requested but not available at link time, falling back to aio.";<commit_msg>fix SimpleAsyncIO build for fboss.<commit_after>/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <folly/experimental/io/SimpleAsyncIO.h>
#include <folly/String.h>
#if __has_include(<folly/experimental/io/AsyncIO.h>) && __has_include(<libaio.h>)
#define AIO_SUPPORTED
#include <folly/experimental/io/AsyncIO.h>
#endif
#if __has_include(<folly/experimental/io/IoUring.h>) && __has_include(<liburing.h>)
#define IOURING_SUPPORTED
#include <folly/experimental/io/IoUring.h>
#endif

#if !defined(AIO_SUPPORTED) && !defined(IOURING_SUPORTED)
#error "Cannot build without at least one of AsyncIO.h and IoUring.h"
#endif

#include <folly/portability/Sockets.h>

namespace folly {

SimpleAsyncIO::SimpleAsyncIO(Config cfg)
    : maxRequests_(cfg.maxRequests_),
      completionExecutor_(cfg.completionExecutor_),
      terminating_(false) {
#if !defined(AIO_SUPPORTED)
  if (cfg.mode_ == AIO) {
    LOG(WARNING)
        << "aio mode requested but not available at link time, falling back to io_uring.";
    cfg.setMode(IOURING);
  }
#endif
#if !defined(IOURING_SUPPORTED)
  if (cfg.mode_ == IOURING) {
    LOG(WARNING)
        << "io_uring mode requested but not available at link time, falling back to aio.";
{'fraction_non_alphanumeric': 0.10733812949640288, 'fraction_numerical': 0.002302158273381295, 'mean_word_length': 4.414330218068536, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5756878', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1080, 'n_words': 343}