An open-source C++ library developed and used at Facebook.

Folly: Facebook Open-source Library

linux mac windows

What is folly?

Logo Folly

Folly (acronymed loosely after Facebook Open Source Library) is a library of C++14 components designed with practicality and efficiency in mind. Folly contains a variety of core library components used extensively at Facebook. In particular, it's often a dependency of Facebook's other open source C++ efforts and place where those projects can share code.

It complements (as opposed to competing against) offerings such as Boost and of course std. In fact, we embark on defining our own component only when something we need is either not available, or does not meet the needed performance profile. We endeavor to remove things from folly if or when std or Boost obsoletes them.

Performance concerns permeate much of Folly, sometimes leading to designs that are more idiosyncratic than they would otherwise be (see e.g. PackedSyncPtr.h, SmallLocks.h). Good performance at large scale is a unifying theme in all of Folly.

Logical Design

Folly is a collection of relatively independent components, some as simple as a few symbols. There is no restriction on internal dependencies, meaning that a given folly module may use any other folly components.

All symbols are defined in the top-level namespace folly, except of course macros. Macro names are ALL_UPPERCASE and should be prefixed with FOLLY_. Namespace folly defines other internal namespaces such as internal or detail. User code should not depend on symbols in those namespaces.

Folly has an experimental directory as well. This designation connotes primarily that we feel the API may change heavily over time. This code, typically, is still in heavy use and is well tested.

Physical Design

At the top level Folly uses the classic "stuttering" scheme folly/folly used by Boost and others. The first directory serves as an installation root of the library (with possible versioning a la folly-1.0/), and the second is to distinguish the library when including files, e.g. #include <folly/FBString.h>.

The directory structure is flat (mimicking the namespace structure), i.e. we don't have an elaborate directory hierarchy (it is possible this will change in future versions). The subdirectory experimental contains files that are used inside folly and possibly at Facebook but not considered stable enough for client use. Your code should not use files in folly/experimental lest it may break when you update Folly.

The folly/folly/test subdirectory includes the unittests for all components, usually named ComponentXyzTest.cpp for each ComponentXyz.*. The folly/folly/docs directory contains documentation.

What's in it?

Because of folly's fairly flat structure, the best way to see what's in it is to look at the headers in top level folly/ directory. You can also check the docs folder for documentation, starting with the overview.

Folly is published on GitHub at https://github.com/facebook/folly

Build Notes

Because folly does not provide any ABI compatibility guarantees from commit to commit, we generally recommend building folly as a static library.

build.sh

The simplest way to build folly is using the build.sh script in the top-level of the repository. build.sh can be used on Linux and MacOS, on Windows use the build.bat script instead.

This script will download and build all of the necessary dependencies first, and will then build folly. This will help ensure that you build with recent versions of all of the dependent libraries, regardless of what versions are installed locally on your system.

By default this script will build and install folly and its dependencies in a scratch directory. You can also specify a --scratch-path argument to control the location of the scratch directory used for the build. There are also --install-dir and --install-prefix arguments to provide some more fine-grained control of the installation directories. However, given that folly provides no compatibility guarantees between commits we generally recommend building and installing the libraries to a temporary location, and then pointing your project's build at this temporary location, rather than installing folly in the traditional system installation directories. e.g., if you are building with CMake you can use the CMAKE_PREFIX_PATH variable to allow CMake to find folly in this temporary installation directory when building your project.

Dependencies

folly supports gcc (5.1+), clang, or MSVC. It should run on Linux (x86-32, x86-64, and ARM), iOS, macOS, and Windows (x86-64). The CMake build is only tested on some of these platforms; at a minimum, we aim to support macOS and Linux (on the latest Ubuntu LTS release or newer.)

folly requires a version of boost compiled with C++14 support.

googletest is required to build and run folly's tests. You can download it from https://github.com/google/googletest/archive/release-1.8.0.tar.gz The following commands can be used to download and install it:

wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \
tar zxf release-1.8.0.tar.gz && \
rm -f release-1.8.0.tar.gz && \
cd googletest-release-1.8.0 && \
cmake . && \
make && \
make install

Finding dependencies in non-default locations

If you have boost, gtest, or other dependencies installed in a non-default location, you can use the CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH variables to make CMAKE look also look for header files and libraries in non-standard locations. For example, to also search the directories /alt/include/path1 and /alt/include/path2 for header files and the directories /alt/lib/path1 and /alt/lib/path2 for libraries, you can invoke cmake as follows:

cmake \
  -DCMAKE_INCLUDE_PATH=/alt/include/path1:/alt/include/path2 \
  -DCMAKE_LIBRARY_PATH=/alt/lib/path1:/alt/lib/path2 ...

Building tests

By default, building the tests is disabled as part of the CMake all target. To build the tests, specify -DBUILD_TESTS=ON to CMake at configure time.

Ubuntu 16.04 LTS

The following packages are required (feel free to cut and paste the apt-get command below):

sudo apt-get install \
    g++ \
    cmake \
    libboost-all-dev \
    libevent-dev \
    libdouble-conversion-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    libiberty-dev \
    liblz4-dev \
    liblzma-dev \
    libsnappy-dev \
    make \
    zlib1g-dev \
    binutils-dev \
    libjemalloc-dev \
    libssl-dev \
    pkg-config \
    libunwind-dev

Folly relies on fmt which needs to be installed from source. The following commands will download, compile, and install fmt.

git clone https://github.com/fmtlib/fmt.git && cd fmt

mkdir _build && cd _build
cmake ..

make -j$(nproc)
sudo make install

If advanced debugging functionality is required, use:

sudo apt-get install \
    libunwind8-dev \
    libelf-dev \
    libdwarf-dev

In the folly directory (e.g. the checkout root or the archive unpack root), run:

  mkdir _build && cd _build
  cmake ..
  make -j $(nproc)
  make install # with either sudo or DESTDIR as necessary

OS X (Homebrew)

folly is available as a Formula and releases may be built via brew install folly.

You may also use folly/build/bootstrap-osx-homebrew.sh to build against master:

  ./folly/build/bootstrap-osx-homebrew.sh

This will create a build directory _build in the top-level.

OS X (MacPorts)

Install the required packages from MacPorts:

  sudo port install \
    boost \
    cmake \
    gflags \
    git \
    google-glog \
    libevent \
    libtool \
    lz4 \
    lzma \
    openssl \
    snappy \
    xz \
    zlib

Download and install double-conversion:

  git clone https://github.com/google/double-conversion.git
  cd double-conversion
  cmake -DBUILD_SHARED_LIBS=ON .
  make
  sudo make install

Download and install folly with the parameters listed below:

  git clone https://github.com/facebook/folly.git
  cd folly
  mkdir _build
  cd _build
  cmake ..
  make
  sudo make install

Windows (Vcpkg)

folly is available in Vcpkg and releases may be built via vcpkg install folly:x64-windows.

You may also use vcpkg install folly:x64-windows --head to build against master.

Other Linux distributions

  • double-conversion (https://github.com/google/double-conversion)

    Download and build double-conversion. You may need to tell cmake where to find it.

    [double-conversion/] ln -s src double-conversion

    [folly/] mkdir build && cd build [folly/build/] cmake "-DCMAKE_INCLUDE_PATH=$DOUBLE_CONVERSION_HOME/include" "-DCMAKE_LIBRARY_PATH=$DOUBLE_CONVERSION_HOME/lib" ..

    [folly/build/] make

  • additional platform specific dependencies:

    Fedora >= 21 64-bit (last tested on Fedora 28 64-bit)

    • gcc
    • gcc-c++
    • cmake
    • automake
    • boost-devel
    • libtool
    • lz4-devel
    • lzma-devel
    • snappy-devel
    • zlib-devel
    • glog-devel
    • gflags-devel
    • scons
    • double-conversion-devel
    • openssl-devel
    • libevent-devel
    • fmt-devel
    • libsodium-devel

    Optional

    • libdwarf-devel
    • elfutils-libelf-devel
    • libunwind-devel
Owner
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
Facebook
Comments
  • [json] Re-enable compilation of JsonTest and add two perf tests

    [json] Re-enable compilation of JsonTest and add two perf tests

    It seems that compiling of the main Json parser unit test was disabled due to a 'MSVC Preprocessor' bug.

    It is safe to assume that g++/clang++ will be used on environments like Linux/etc while MSVC would be used on MS-Windows.

    This change will re-enable the unit test compilation while also adding two new unit tests targeting stressing the performance of the Json parser.

  • Issues with Visual C++ compiler

    Issues with Visual C++ compiler

    • [x] folly/Malloc.h(193): error C2059: syntax error: 'volatile' PR #688
    • [x] folly/detail/Crc32cDetail.cpp(208): fatal error C1009: compiler limit: macros nested too deeply
    • [x] folly/executors/NamedThreadFactory.h(38): error C2665: 'folly::setThreadName': none of the 2 overloads could convert all the argument types
    • [x] folly can't link with static libraries https://gist.github.com/KindDragon/c4e6414bd60242d317bb0387a82dce61#file-package-x64-windows-static-rel-out-log-L2291 PR #693
    • [x] folly/futures/Future-inl.h(242): error C2244: 'folly::SemiFuture::SemiFuture': unable to match function definition to an existing declaration
    • [x] folly/io/async/AsyncSocket.cpp(1589): error C2039: 'Control': is not a member of 'msghdr'. Win10 SDK define MSG_ERRQUEUE too https://naughter.wordpress.com/2017/07/16/changes-in-the-windows-v10-0-16232-sdk-compared-to-windows-v10-0-15063-sdk-part-one/ PR #689
    • [x] folly/io/async/AsyncSocket.cpp(939): error C2065: 'SOL_IP': undeclared identifier
    • [x] folly/stats/Histogram.cpp(43): error C5037: 'folly::detail::HistogramBuckets<__int64,folly::detail::Bucket>::getPercentileBucketIdx': an out-of-line definition of a member of a class template cannot have default arguments with [T=int64_t] MSVC 2017U4 PR #691
    • [x] folly/synchronization/CallOnce.h(86): error C2988: unrecognizable template declaration/definition. CallOnce.h(98): note: see reference to class template instantiation 'folly::detail::once_flag' being compiled https://github.com/facebook/folly/commit/b529367b595dd4da7e70569cbea36d30ace4fa39#commitcomment-25665382
    • [x] folly\Random.cpp(43): error C2672: 'folly::detail::once_flagfolly::SharedMutex::{dtor}': no matching overloaded function found
    • [x] GroupVarint.cpp(134): error C2370: 'folly::detail::groupVarintSSEMasks': redefinition; different storage class
    • [x] Format.cpp(82): error C2370: 'folly::detail::formatHexLower': redefinition; different storage class. Same on lines 84, 86, 88
    • [x] Futex.h(47): error C2039: 'Atom': is not a member of 'std::atomic' https://ci.appveyor.com/project/KindDragon/folly/build/20/job/p3kt29bxfggn3ib7#L251
    • [x] AsyncSocket.cpp(986): error C3861: 'BOOST_PP_IIF_BOOST_PP_BOOL_FOLLY_HAVE_VLA': identifier not found https://ci.appveyor.com/project/KindDragon/folly/build/31/job/45bx663tx1m62n8k#L3198
    • [x] Rcu code crash at exit
    • [x] VS2015 folly/ConstexprMath.h(57): error C3250: 'folly::constexpr_clamp::Less': declaration is not allowed in 'constexpr' function body

    /cc @Orvid

  • Mac OS build, help needed.

    Mac OS build, help needed.

    Hi.

    Trying to build folly on Mac OS. I would like to contribute, so I need to be able to build tests and benchmarks - I cannot just take the brew installation.

    bootstrap-osx-homebrew.sh fails with "autoreconf: 'configure.ac' or 'configure.in' is required" I googled - seems like running it is no longer relevant.

    CMAKE fails due to not being able to find dependencies:

    -- Could NOT find DOUBLE_CONVERSION (missing: DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR) 
    -- Using third-party bundled double-conversion
    -- Could NOT find LIBGFLAGS (missing: LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR) 
    -- Could NOT find LIBGLOG (missing: LIBGLOG_LIBRARY LIBGLOG_INCLUDE_DIR) 
    -- Found libevent: /usr/local/lib/libevent.dylib
    -- Found OpenSSL: /usr/lib/libcrypto.dylib (found version "1.0.2p") 
    -- Looking for ASN1_TIME_diff
    CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
    Please set them or make sure they are set and tested correctly in the CMake files:
    LIBGFLAGS_INCLUDE_DIR
       used as include directory in directory /space/folly/_build/CMakeFiles/CMakeTmp
       used as include directory in directory /space/folly/_build/CMakeFiles/CMakeTmp
       used as include directory in directory /space/folly/_build/CMakeFiles/CMakeTmp
    LIBGFLAGS_LIBRARY
        linked by target "cmTC_e2f29" in directory /space/folly/_build/CMakeFiles/CMakeTmp
    
    CMake Error at /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/CheckFunctionExists.cmake:72 (try_compile):
      Failed to configure test project build system.
    Call Stack (most recent call first):
      CMake/folly-deps.cmake:75 (check_function_exists)
      CMakeLists.txt:85 (include)
    
    
    -- Configuring incomplete, errors occurred!
    

    Could you please give instructions on how to build folly: from clear download to running tests and benchmarks?

  • Add memory padding and alignment to prevent false sharing

    Add memory padding and alignment to prevent false sharing

    Ensure no thirdparty thread writes to a cacheline shared by our ringbuffer, readIndex and writeIndex. Ensure readIndex and writeIndex are located on different cachelines.

  • Prevent IsOneOf unused template specialization instantiation

    Prevent IsOneOf unused template specialization instantiation

    Current IsOneOf implementation does unnecessary work because it instantiates all of the possible template specializations, even if type is same as the first of the tested ones. E.g. IsOneOf<char, char, int, float> will instantiate:

    IsOneOf<char, char, int, float>
    IsOneOf<char, char, int>
    IsOneOf<char, char>
    IsOneOf<char>
    

    With the proposed inheritance, compiler will stop initializing at the first match.

  • $<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets

    $ may only be used with binary targets

    I'm building folly v2020.07.13.00 on Ubuntu 18.04 x86_64 with the standard system gcc but a newer cmake 3.18.0. On configure, I get the cmake error:

    [...]
     -- Found gmock via config, defines=, include=/data/Debug/include, libs=GTest::gmock_main;GTest::gmock;GTest::gtest
     -- Found GTest: /data/Debug/lib/libgtest.a  
     -- Configuring done
     CMake Error at CMakeLists.txt:446 (file):
       Error evaluating generator expression:
         $<COMPILE_LANG_AND_ID:CUDA,NVIDIA>
       $<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to
       specify include directories, compile definitions, and compile options.  It
       may not be used with the add_custom_command, add_custom_target, or
       file(GENERATE) commands.
     CMake Error at CMakeLists.txt:446 (file):
       Error evaluating generator expression:
         $<COMPILE_LANG_AND_ID:CUDA,NVIDIA>
       $<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to
       specify include directories, compile definitions, and compile options.  It
       may not be used with the add_custom_command, add_custom_target, or
       file(GENERATE) commands.
     -- Generating done
    

    cmake ends in error after that. I googled for this problem but could not find anything really useful. Also I can not find the lines $<COMPILE_LANG_AND_ID:CUDA,NVIDIA> in folly so I'm slightly confused where the problem originates from. Can someone point me in the right direction please?

  • Fix bootstrap-osx-homebrew.sh to work with CMake builds

    Fix bootstrap-osx-homebrew.sh to work with CMake builds

    Summary:

    • The bootstrap-osx-homebrew.sh script is out of date. It previously worked when Folly used Autotools, but was not updated when CMake replaced Autotools for the build system.
    • Update dependencies to install.
    • Do not export environment variables when it is not needed; simply pass the defines needed directly to the cmake invocation.
    • Update README.md to specify correct dependencies with CMake build for both Homebrew and Macports.

    Closes #1038

  • CHECK failed in SingletonThreadLocal.h in gcc 7.4.0 and 8.3.0 because of gcc bug

    CHECK failed in SingletonThreadLocal.h in gcc 7.4.0 and 8.3.0 because of gcc bug

    As 7.4.0 is the default version that ships with Ubuntu 18.04, this might be worth working around.

    Tried with both gcc 7.4.0 and 8.3.0 on Ubuntu 18.04 LTS, x86_64.

    https://github.com/facebook/folly/commit/d6dd4b4767bd1763c48fe96b3a01607667f2336a assumes that thread_local objects inside of inline functions have the same address, as they should, but that's not true across shared-library boundaries in gcc, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90562

    cc: @yfeldblum @djwatson @igorcanadi

  • Two changes to make folly able to build in CygWin

    Two changes to make folly able to build in CygWin

    1. Make the generate_fingerprint_tables exec have .exe as file extension on Windows platform;
    2. Make an impl of clearenv() in C++ for Windows, CygWin and Apple platforms.
  • [2021.05.17.00] Fails to build on FreeBSD: error: no member named '__cxa_allocate_exception' in namespace '__cxxabiv1'

    [2021.05.17.00] Fails to build on FreeBSD: error: no member named '__cxa_allocate_exception' in namespace '__cxxabiv1'

    wrkdirs/usr/ports/devel/folly/work/folly-2021.05.17.00/folly/lang/Exception.cpp:180:24: error: no member named '__cxa_allocate_exception' in namespace '__cxxabiv1'
        auto object = abi::__cxa_allocate_exception(0);
                      ~~~~~^
    /wrkdirs/usr/ports/devel/folly/work/folly-2021.05.17.00/folly/lang/Exception.cpp:190:10: error: no type named '__cxa_free_exception' in namespace '__cxxabiv1'; did you mean '__cxa_exception'?
        abi::__cxa_free_exception(object); // no need for decref
        ~~~~~^~~~~~~~~~~~~~~~~~~~
             __cxa_exception
    /usr/include/c++/v1/cxxabi.h:77:8: note: '__cxa_exception' declared here
    struct __cxa_exception
           ^
    /wrkdirs/usr/ports/devel/folly/work/folly-2021.05.17.00/folly/lang/Exception.cpp:190:30: warning: parentheses were disambiguated as redundant parentheses around declaration of variable named 'object' [-Wvexing-parse]
        abi::__cxa_free_exception(object); // no need for decref
                                 ^~~~~~~~
    /wrkdirs/usr/ports/devel/folly/work/folly-2021.05.17.00/folly/lang/Exception.cpp:190:5: note: add enclosing parentheses to perform a function-style cast
        abi::__cxa_free_exception(object); // no need for decref
        ^
        (                                )
    /wrkdirs/usr/ports/devel/folly/work/folly-2021.05.17.00/folly/lang/Exception.cpp:190:30: note: remove parentheses to silence this warning
        abi::__cxa_free_exception(object); // no need for decref
                                 ^      ~
    
    /wrkdirs/usr/ports/devel/folly/work/folly-2021.05.17.00/folly/lang/Exception.cpp:190:31: error: redefinition of 'object'
        abi::__cxa_free_exception(object); // no need for decref
                                  ^
    /wrkdirs/usr/ports/devel/folly/work/folly-2021.05.17.00/folly/lang/Exception.cpp:180:10: note: previous definition is here
        auto object = abi::__cxa_allocate_exception(0);
             ^
    1 warning and 3 errors generated.
    

    2021.05.10.00 was building fine.

    FreeBSD 12.2 clang-10

  • Fix some `CMAKE_REQUIRED_FLAGS` stuff

    Fix some `CMAKE_REQUIRED_FLAGS` stuff

    This fixes two issues related to CMAKE_REQUIRED_FLAGS


    CMAKE_REQUIRED_FLAGS, unlike the other CMAKE_REQUIRED_* variables, is a string, not a list. A list with more than one item in CMAKE_REQUIRED_FLAGS results in a semicolon showing up in the middle of the command line for at least check_symbol_exists and check_type_size calls, prematurely terminating the compilation command and resulting in potentially incorrect CMake test failures.

    For example, CMake fails to determine the size of __int128 on macOS 10.13.3, with Apple Clang 9 (clang-900.0.39.2), even though __int128 is supported for this platform, as the following C program

    int main() {
        __int128 i;
    }
    

    compiles successfully with the command "clang test.c". CMake fails to compile a program with __int128 for an entirely different reason:

    Building CXX object CMakeFiles/cmTC_d7e3f.dir/INT128_SIZE.cpp.o
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -DGFLAGS_IS_A_DLL=0 -isystem /usr/local/include -I/usr/local/opt/[email protected]/include  -fsanitize=address,undefined -std=gnu++14;-Werror=unknown-warning-option   -o CMakeFiles/cmTC_d7e3f.dir/INT128_SIZE.cpp.o -c /Users/awang/code/CRES/scc-analysis/build-debug/CMakeFiles/CheckTypeSize/INT128_SIZE.cpp
    clang: error: no input files
    /bin/sh: -Werror=unknown-warning-option: command not found
    make[1]: *** [CMakeFiles/cmTC_d7e3f.dir/INT128_SIZE.cpp.o] Error 127
    make: *** [cmTC_d7e3f/fast] Error 2
    

    Using set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} <new_flag>") avoids this problem.


    CMAKE_REQUIRED_FLAGS is given to both C and C++ compiler invocations. The C++-specific flag -std=gnu++14 causes compilation to fail on Apple LLVM 9.1.0 (clang-902.0.39.2) with errors along the lines of:

    Building C object CMakeFiles/cmTC_af532.dir/CheckSymbolExists.c.o
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -DGFLAGS_IS_A_DLL=0 -isystem /usr/local/include -I/usr/local/opt/[email protected]/include  -std=gnu++14   -o CMakeFiles/cmTC_af532.dir/CheckSymbolExists.c.o   -c /Users/awang/code/CRES/scc-analysis/build-debug/CMakeFiles/CMakeTmp/CheckSymbolExists.c
    error: invalid argument '-std=gnu++14' not allowed with 'C/ObjC'
    make[1]: *** [CMakeFiles/cmTC_af532.dir/CheckSymbolExists.c.o] Error 1
    make: *** [cmTC_af532/fast] Error 2
    

    The affected functions are:

    • pthread_atfork
    • memrchr
    • preadv
    • pwritev
    • clock_gettime
    • cplus_demangle_v3_callback
    • malloc_usable_size

    Of these, only pthread_atfork and clock_gettime were detected as being absent when they were actually present.

    The failure to correctly identify the presence of pthread_atfork, at least, can cause Folly to fail to build on macOS because Folly requires pthread_atfork for macOS but thinks it is absent due to the failed test.

  • Build fails with FOLLY_USE_JEMALLOC=OFF

    Build fails with FOLLY_USE_JEMALLOC=OFF

    In file included from /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/ExceptionString.cpp:17:
    In file included from /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/ExceptionString.h:21:
    In file included from /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/FBString.h:44:
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:103:9: error: use of undeclared identifier 'mallocx'; did you mean 'malloc'?
        if (mallocx == nullptr || rallocx == nullptr || xallocx == nullptr ||
            ^~~~~~~
            malloc
    /usr/include/stdlib.h:106:7: note: 'malloc' declared here
    void    *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
             ^
    In file included from /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/ExceptionString.cpp:17:
    In file included from /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/ExceptionString.h:21:
    In file included from /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/FBString.h:44:
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:103:9: warning: comparison of function 'malloc' equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (mallocx == nullptr || rallocx == nullptr || xallocx == nullptr ||
            ^~~~~~~    ~~~~~~~
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:103:9: note: prefix with the address-of operator to silence this warning
        if (mallocx == nullptr || rallocx == nullptr || xallocx == nullptr ||
            ^
            &
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:103:31: error: use of undeclared identifier 'rallocx'
        if (mallocx == nullptr || rallocx == nullptr || xallocx == nullptr ||
                                  ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:103:53: error: use of undeclared identifier 'xallocx'
        if (mallocx == nullptr || rallocx == nullptr || xallocx == nullptr ||
                                                        ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:104:9: error: use of undeclared identifier 'sallocx'
            sallocx == nullptr || dallocx == nullptr || sdallocx == nullptr ||
            ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:104:31: error: use of undeclared identifier 'dallocx'
            sallocx == nullptr || dallocx == nullptr || sdallocx == nullptr ||
                                  ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:104:53: error: use of undeclared identifier 'sdallocx'
            sallocx == nullptr || dallocx == nullptr || sdallocx == nullptr ||
                                                        ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:105:9: error: use of undeclared identifier 'nallocx'
            nallocx == nullptr || mallctl == nullptr ||
            ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:105:31: error: use of undeclared identifier 'mallctl'
            nallocx == nullptr || mallctl == nullptr ||
                                  ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:106:9: error: use of undeclared identifier 'mallctlnametomib'
            mallctlnametomib == nullptr || mallctlbymib == nullptr) {
            ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:106:40: error: use of undeclared identifier 'mallctlbymib'
            mallctlnametomib == nullptr || mallctlbymib == nullptr) {
                                           ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:103:9: warning: comparison of function 'malloc' equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (mallocx == nullptr || rallocx == nullptr || xallocx == nullptr ||
            ^~~~~~~    ~~~~~~~
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:103:9: note: prefix with the address-of operator to silence this warning
        if (mallocx == nullptr || rallocx == nullptr || xallocx == nullptr ||
            ^
            &
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:115:9: error: use of undeclared identifier 'mallctl'
        if (mallctl(
            ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:180:9: error: use of undeclared identifier 'sdallocx'
            sdallocx == nullptr || nallocx == nullptr) {
            ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:180:32: error: use of undeclared identifier 'nallocx'
            sdallocx == nullptr || nallocx == nullptr) {
                                   ^
    /disk-samsung/freebsd-ports/devel/folly/work/folly-2022.11.28.00/folly/memory/Malloc.h:338:13: error: use of undeclared identifier 'nallocx'; did you mean 'calloc'?
      auto rv = nallocx(minSize, 0);
                ^~~~~~~
                calloc
    /usr/include/stdlib.h:98:7: note: 'calloc' declared here
    void    *calloc(size_t, size_t) __malloc_like __result_use_check
             ^
    

    Version: 2022.11.28.00 clang-14 OS: FreeBSD 13.1

  • Cannot build on MacOS and use it for a project.

    Cannot build on MacOS and use it for a project.

    I follow all the steps of installing the dependencies and run the build scripts. But I got the following error and it doesn't seem like that the library is truly installed.

    The following tests FAILED: 329 - cache_locality_test.CoreRawAllocator.Basic (Failed) 721 - xlog_test.XlogTest.xlogIf (Failed) 722 - xlog_test.XlogTest.xlog (Failed) 724 - xlog_test.XlogTest.rateLimiting (Failed) 725 - xlog_test.XlogTest.rateLimitingEndOfThread (Failed) 1514 - arena_test.Arena.SizeSanity (Failed) Errors while running CTest Command '['/opt/homebrew/opt/cmake/bin/ctest', '--output-on-failure', '-j', '8', '--rerun-failed']' returned non-zero exit status 8. !! Failed

  • xlog test error

    xlog test error

    1/4 Test #717: xlog_test.XlogTest.xlogIf ....................***Failed 0.06 sec Note: Google Test filter = XlogTest.xlogIf [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from XlogTest [ RUN ] XlogTest.xlogIf /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:87: Failure Expected equality of these values: 1 messages.size() Which is: 0 [ FAILED ] XlogTest.xlogIf (0 ms) [----------] 1 test from XlogTest (0 ms total)

    [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (0 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] XlogTest.xlogIf

    1 FAILED TEST

    2/4 Test #718: xlog_test.XlogTest.xlog ......................***Failed 0.06 sec Note: Google Test filter = XlogTest.xlog [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from XlogTest [ RUN ] XlogTest.xlog /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:152: Failure Expected equality of these values: 1 messages.size() Which is: 0 [ FAILED ] XlogTest.xlog (0 ms) [----------] 1 test from XlogTest (0 ms total)

    [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (0 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] XlogTest.xlog

    1 FAILED TEST

    3/4 Test #721: xlog_test.XlogTest.rateLimitingEndOfThread ...***Failed 0.07 sec Note: Google Test filter = XlogTest.rateLimitingEndOfThread [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from XlogTest [ RUN ] XlogTest.rateLimitingEndOfThread /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:492: Failure Value of: handler->getMessageValues() Expected: has 12 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 7", element #2 is equal to "msg 14", element #3 is equal to "msg 21", element #4 is equal to "msg 28", element #5 is equal to "msg 35", element #6 is equal to "msg 42", element #7 is equal to "msg 49", element #8 is equal to "dtor 100", element #9 is equal to "dtor 101", element #10 is equal to "dtor 102", element #11 is equal to "dtor 103" Actual: {} [ FAILED ] XlogTest.rateLimitingEndOfThread (0 ms) [----------] 1 test from XlogTest (0 ms total)

    [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (0 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] XlogTest.rateLimitingEndOfThread

    1 FAILED TEST

    4/4 Test #720: xlog_test.XlogTest.rateLimiting ..............***Failed 0.18 sec Note: Google Test filter = XlogTest.rateLimiting [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from XlogTest [ RUN ] XlogTest.rateLimiting /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:297: Failure Value of: handler->getMessageValues() Expected: has 8 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 7", element #2 is equal to "msg 14", element #3 is equal to "msg 21", element #4 is equal to "msg 28", element #5 is equal to "msg 35", element #6 is equal to "msg 42", element #7 is equal to "msg 49" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:306: Failure Value of: handler->getMessageValues() Expected: has 7 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 8", element #2 is equal to "msg 16", element #3 is equal to "msg 24", element #4 is equal to "msg 32", element #5 is equal to "msg 40", element #6 is equal to "msg 48" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:316: Failure Value of: handler->getMessageValues() Expected: has 4 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 14", element #2 is equal to "msg 28", element #3 is equal to "msg 42" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:325: Failure Value of: handler->getMessageValues() Expected: has 7 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 8", element #2 is equal to "msg 16", element #3 is equal to "msg 24", element #4 is equal to "msg 32", element #5 is equal to "msg 40", element #6 is equal to "msg 48" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:342: Failure Value of: handler->getMessageValues() Expected: has 8 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 7", element #2 is equal to "msg 14", element #3 is equal to "msg 21", element #4 is equal to "msg 28", element #5 is equal to "msg 35", element #6 is equal to "msg 42", element #7 is equal to "msg 49" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:351: Failure Value of: handler->getMessageValues() Expected: has 7 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 8", element #2 is equal to "msg 16", element #3 is equal to "msg 24", element #4 is equal to "msg 32", element #5 is equal to "msg 40", element #6 is equal to "msg 48" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:368: Failure Value of: handler->getMessageValues() Expected: has 8 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 7", element #2 is equal to "msg 14", element #3 is equal to "msg 21", element #4 is equal to "msg 28", element #5 is equal to "msg 35", element #6 is equal to "msg 42", element #7 is equal to "msg 49" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:377: Failure Value of: handler->getMessageValues() Expected: has 7 elements where element #0 is equal to "msg 0", element #1 is equal to "msg 8", element #2 is equal to "msg 16", element #3 is equal to "msg 24", element #4 is equal to "msg 32", element #5 is equal to "msg 40", element #6 is equal to "msg 48" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:434: Failure Value of: handler->getMessageValues() Expected: has 21 elements where element #0 is equal to "int arg 0", element #1 is equal to "ms arg 0", element #2 is equal to "s arg 0", element #3 is equal to "s arg capture 0", element #4 is equal to "fmt arg 0", element #5 is equal to "fmt ms arg 0", element #6 is equal to "2x int arg 0", element #7 is equal to "1x ms arg 0", element #8 is equal to "3x s arg 0", element #9 is equal to "2x int arg 1", element #10 is equal to "3x s arg 1", element #11 is equal to "3x s arg 2", element #12 is equal to "int arg conditional 2", element #13 is equal to "int arg 6", element #14 is equal to "ms arg 6", element #15 is equal to "fmt arg 6", element #16 is equal to "fmt ms arg 6", element #17 is equal to "2x int arg 6", element #18 is equal to "1x ms arg 6", element #19 is equal to "int arg conditional 6", element #20 is equal to "2x int arg 7" Actual: {} /Users/zhangshuo/work/folly/folly/logging/test/XlogTest.cpp:448: Failure Value of: handler->getMessageValues() Expected: has 4 elements where element #0 is equal to "bah 0", element #1 is equal to "bah 1", element #2 is equal to "bah 2", element #3 is equal to "bah 3" Actual: {} [ FAILED ] XlogTest.rateLimiting (114 ms) [----------] 1 test from XlogTest (114 ms total)

    [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (114 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] XlogTest.rateLimiting

    1 FAILED TEST

    0% tests passed, 4 tests failed out of 4

    Total Test time (real) = 6.97 sec

    The following tests FAILED: 717 - xlog_test.XlogTest.xlogIf (Failed) 718 - xlog_test.XlogTest.xlog (Failed) 720 - xlog_test.XlogTest.rateLimiting (Failed) 721 - xlog_test.XlogTest.rateLimitingEndOfThread (Failed) Errors while running CTest

    ============================================================ is this a bug?

  • how to resolve __cxa_throw multi-definition

    how to resolve __cxa_throw multi-definition

    I defined my own specific __cxa_throw to overwrite the original function in the system. But when I linked libfolly.a, it output errors for multi-definition of __cxa_throw. For there is __cxa_throw defined in folly/experimental/exception_tracer/ExceptionTracerLib.cpp. How can I resolved this problem?

  • How to port FreeRTOS-style code to Folly?

    How to port FreeRTOS-style code to Folly?

    Hi I have an existing project written in FreeRTOS style running on 32-bit MCUs, but wishing to port over to a Linux environment, e.g. Zynq Petalinux. How do I refactor the code to utilize Folly APIs?

    For example, I have a blinking LED flashing at 1 second interval. I also hook up a push button to toggle the blinking LED. Like this FreeRTOS-style pseudo code:

    std::atomic_bool is_led_on = false;
    static ThreadPool{.n_worker = 3};
    
    void loopLED() noexcept {
       setupLED();
       bool led_blink_state = true;
       for(;;) {
             if(is_led_on) {
                  digitalWrite(led_blink_state);
                  led_blink_state = ! led_blink_state;
                  
                  using std::chrono_literal;
             } else {
                  digitalWrite(false);
             }
             ThreadPool.schedule_after(1000ms);
       }
       teardownLED();
    }
    
    void loopButton() noexcept {
        setupButtion();
        for (;;) {
            if (button1.is_pressed()) {
                is_led_on = ! is_led_on;
            }
            using std::chrono_literal;
            ThreadPool.schedule_after(200ms);
        }
        teardownButton();
    }
    

    In particular, how do I retain the setup -> event loop -> teardown coding pattern per task in Folly? Or, should I move the for(;;){} to somewhere else, in order to utilize Folly well?

    I understand running such an example with Folly is an overkill. In a more realistic example the "LEDs" would have been CAN-bus handshakes over 10+ remote hardware components; the "button" would have been a command parser of the incoming /dev/stdin stream.

An open source library for C

Homo Deus - C Library Introduction The Homo Deus C Library (hdelibc) is an open source collection of tools for the C programming language. The project

Nov 28, 2022
JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, RTAS and AAX audio plug-ins.
JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, RTAS and AAX audio plug-ins.

JUCE is an open-source cross-platform C++ application framework used for rapidly developing high quality desktop and mobile applications, including VS

Dec 1, 2022
Basic Development Environment - a set of foundational C++ libraries used at Bloomberg.

BDE Libraries This repository contains the BDE libraries, currently BSL (Basic Standard Library), BDL (Basic Development Library), BAL (Basic Applicat

Nov 24, 2022
Fast, orthogonal, open multi-methods. Supersedes yomm11.

YOMM2 This is a complete rewrite of YOMM11, which is now deprecated. This library is much better, see here to find out why. TL;DR If you are familiar

Nov 23, 2022
Nov 27, 2022
EASTL stands for Electronic Arts Standard Template Library. It is an extensive and robust implementation that has an emphasis on high performance.

EA Standard Template Library EASTL stands for Electronic Arts Standard Template Library. It is a C++ template library of containers, algorithms, and i

Dec 1, 2022
Functional Programming Library for C++. Write concise and readable C++ code.
Functional Programming Library for C++. Write concise and readable C++ code.

FunctionalPlus helps you write concise and readable C++ code. Table of contents Introduction Usage examples Type deduction and useful error messages T

Nov 28, 2022
Embedded Template Library

Embedded Template Library (ETL) Motivation C++ is a great language to use for embedded applications and templates are a powerful aspect. The standard

Nov 26, 2022
? A glib-like multi-platform c library
? A glib-like multi-platform c library

A glib-like cross-platform C library Supporting the project Support this project by becoming a sponsor. Your logo will show up here with a link to you

Nov 27, 2022
NIH Utility Library

libnih is a light-weight "standard library" of C functions to ease the development of other libraries and applications. Its goals are: * despite it

Sep 15, 2022
A toolkit for making real world machine learning and data analysis applications in C++

dlib C++ library Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real worl

Nov 24, 2022
An eventing framework for building high performance and high scalability systems in C.

NOTE: THIS PROJECT HAS BEEN DEPRECATED AND IS NO LONGER ACTIVELY MAINTAINED As of 2019-03-08, this project will no longer be maintained and will be ar

Nov 20, 2022
C++14 evented IO libraries for high performance networking and media based applications

LibSourcey C++ Networking Evolved LibSourcey is a collection of cross platform C++14 modules and classes that provide developers with an arsenal for r

Nov 22, 2022
Easy to use, header only, macro generated, generic and type-safe Data Structures in C
Easy to use, header only, macro generated, generic and type-safe Data Structures in C

C Macro Collections Easy to use, header only, macro generated, generic and type-safe Data Structures in C. Table of Contents Installation Contributing

Nov 23, 2022
A collection of single-file C libraries. (generic containers, random number generation, argument parsing and other functionalities)

cauldron A collection of single-file C libraries and tools with the goal to be portable and modifiable. Libraries library description arena-allocator.

Oct 26, 2022
C++ Parallel Computing and Asynchronous Networking Engine

As Sogou`s C++ server engine, Sogou C++ Workflow supports almost all back-end C++ online services of Sogou, including all search services, cloud input method´╝îonline advertisements, etc., handling more than 10 billion requests every day. This is an enterprise-level programming engine in light and elegant design which can satisfy most C++ back-end development requirements.

Nov 25, 2022
Idle is an asynchronous and hot-reloadable C++ dynamic component framework
Idle is an asynchronous and hot-reloadable C++ dynamic component framework

Idle is an asynchronous, hot-reloadable, and highly reactive dynamic component framework similar to OSGI that is: ?? Modular: Your program logic is en

Nov 29, 2022
Flint++ is cross-platform, zero-dependency port of flint, a lint program for C++ developed and used at Facebook.

Flint++ A Cross Platform Port of Facebook's C++ Linter Flint++ is cross-platform, zero-dependency port of flint, a lint program for C++ developed and

Oct 17, 2022
The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-source and can be used with OpenOCD as a general-purpose programmer
The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-source and can be used with OpenOCD as a general-purpose programmer

pico-probe-programmer The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-sou

Oct 15, 2022
A continuation of FSund's pteron-keyboard project. Feel free to contribute, or use these files to make your own! Kits and PCBs are also available through my facebook page.
A continuation of FSund's pteron-keyboard project. Feel free to contribute, or use these files to make your own! Kits and PCBs are also available through my facebook page.

pteron-pcb Intro This project is the evolution of the Pteron-Keyboard project, an incredible ergonomic keyboard that was handwired only. I aimed to in

Oct 11, 2022