1. 15 Mar, 2016 1 commit
    • Michael Lee's avatar
      Missing guards for FOLLY_TLS in test · f4a80a41
      Michael Lee authored
      Summary:defined(FOLLY_TLS) is guarded once in the test, so we should
      guard for it throughout.  Also a missing header for some platforms.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3049797
      
      fb-gh-sync-id: 5d66c71dda94c57a2e50aee96d55be1c574bf921
      shipit-source-id: 5d66c71dda94c57a2e50aee96d55be1c574bf921
      f4a80a41
  2. 14 Mar, 2016 3 commits
    • Sven Over's avatar
      folly/portability/Constexpr.h: add missing include statement · b1e0c2c8
      Sven Over authored
      Summary:This commit fixes compiler errors when Constexpr.h was included
      on gcc before cstring (or string.h) was included. Also, qualify
      the call to strlen with the std namespace.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3047417
      
      fb-gh-sync-id: 7a50dac2e9449b149062896f34fa5e864f767943
      shipit-source-id: 7a50dac2e9449b149062896f34fa5e864f767943
      b1e0c2c8
    • Michael Lee's avatar
      Fix a typo in portability/Memory.cpp · bddb362e
      Michael Lee authored
      Summary: Also, add error checking back in, and remove the empty WIN32 implementation.
      
      Reviewed By: francis-ma
      
      Differential Revision: D3047494
      
      fb-gh-sync-id: 5a2a18cd1ca675a081ad2a9252c765ab56527b6b
      shipit-source-id: 5a2a18cd1ca675a081ad2a9252c765ab56527b6b
      bddb362e
    • Jimmy Saade's avatar
      folly::FunctionScheduler: Adding capability to reset a function's timer · 13c58db9
      Jimmy Saade authored
      Summary:Adding support for resetting a specified function's timer.
      
      "Resetting a function's timer" effectively means "canceling whatever next runs it would have had, and treating it as though it were just added".
      When `resetFunctionTimer` is called, the specified function's interval (timer) will be reset, and it will execute after its initially-specified `startDelay`. If the `startDelay` is zero, the function will execute immediately, and then be scheduled as before - once every `interval` milliseconds.
      
      Motivation: batch processing of updates, where both a size and time limit are in play. If the size limit is reached, it makes sense to reset the timer for the scheduled function.
      
      Differential Revision: D3045868
      
      fb-gh-sync-id: a5ceb0069c04a77fdab16b61679987ee55484e89
      shipit-source-id: a5ceb0069c04a77fdab16b61679987ee55484e89
      13c58db9
  3. 13 Mar, 2016 1 commit
    • Giuseppe Ottaviano's avatar
      Fix warning in MicroLock initialization · 1c15b5bb
      Giuseppe Ottaviano authored
      Summary:The `init()` function uses the previous value of `lock_`, but that is
      uninitialized and the compiler can issue a warning about it. It is
      also potentially undefined behavior because it is not guaranteed that
      the address of `lock_` is taken before `init()` (in which case the it
      would be just an indeterminate value).
      
      Since it is not very useful to initialize only one slot and leave the
      others uninitialized, we can just have a single `init()` that
      zero-initializes all the slots.
      
      Reviewed By: dcolascione
      
      Differential Revision: D3042629
      
      fb-gh-sync-id: de1633b02eb1c891e310f2d5d2cfc5376cd41d5f
      shipit-source-id: de1633b02eb1c891e310f2d5d2cfc5376cd41d5f
      1c15b5bb
  4. 12 Mar, 2016 3 commits
    • Daniel Colascione's avatar
      Explain union safety in MicroLock comment · b29f38a4
      Daniel Colascione authored
      Reviewed By: ot
      
      Differential Revision: D3045850
      
      fb-gh-sync-id: ee19b146c43410d8d8804c9bfe79c3811394b10e
      shipit-source-id: ee19b146c43410d8d8804c9bfe79c3811394b10e
      b29f38a4
    • Wez Furlong's avatar
      folly: fix gflags<->glog configure check ordering · 4bdddb9e
      Wez Furlong authored
      Summary:On systems that do not have gflags or glog installed globally,
      but only locally as static libraries, our configure check failed for
      glog because we were checking it prior to gflags.
      
      glog depends on gflags, but when the libraries are static, there is
      no explicit dependency information available and the linker fails.
      
      This resolves the issue by checking for gflags first; this causes
      configure to add an implicit `-lgflags` for the subsequent glog
      tests.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3044138
      
      fb-gh-sync-id: 5e07ce52842c6e4cff796560672bf950e2fafe6c
      shipit-source-id: 5e07ce52842c6e4cff796560672bf950e2fafe6c
      4bdddb9e
    • Michael Lee's avatar
      Remove portability/Stdlib.{h,cpp} · 5ae81138
      Michael Lee authored
      Summary: This was wrong and is like better solved, not with a shim layer, but by not using such a platform-specific function in the first place.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3001253
      
      fb-gh-sync-id: 460cc46b1c9adc3d229a07cb290270f7afbbb1e0
      shipit-source-id: 460cc46b1c9adc3d229a07cb290270f7afbbb1e0
      5ae81138
  5. 11 Mar, 2016 1 commit
    • Michael Lee's avatar
      Adding portability to gating PicoSpinLock. · b1eb6819
      Michael Lee authored
      Summary:PicoSpinLock only works on x86_64, Arm64, and ppc64 (i.e.,
      not 32-bit).  Add a bit of gating so we can continue to run tests and
      use headers when compiling for i386.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2991328
      
      fb-gh-sync-id: b0d0c229508f65dff62b24fdd9d80c799cd97935
      shipit-source-id: b0d0c229508f65dff62b24fdd9d80c799cd97935
      b1eb6819
  6. 10 Mar, 2016 1 commit
  7. 09 Mar, 2016 5 commits
    • Giuseppe Ottaviano's avatar
      Port easy instances to folly::dynamic::array · e84e7fad
      Giuseppe Ottaviano authored
      Summary:The vast majority of `folly::dynamic` array initializations are
      single-line and with no nested arrays, so we can fix them with a
      syntactic codemod. This also fixes a couple of singletons.
      
      For empty arrays:
      ```
      codemod '((?:folly::)?)(dynamic\s+\w+\s*=\s*)({\s*})' '\1\2\1dynamic::array'
      ```
      
      For non-empty ones:
      ```
      codemod '((?:folly::)?)(dynamic\s+\w+\s*=\s*)(?:{\s*([^{}]+?)\s*})' '\1\2\1dynamic::array(\3)'
      ```
      
      Reviewed By: igorsugak
      
      Differential Revision: D3030338
      
      fb-gh-sync-id: 3e56704a6c6294d6f6270e42a1776d991a7938df
      shipit-source-id: 3e56704a6c6294d6f6270e42a1776d991a7938df
      e84e7fad
    • Kyle Nekritz's avatar
      Add replay safety connector/handler to delay transactions scheduled on a replay-unsafe transport. · d00a7c52
      Kyle Nekritz authored
      Summary: This allows HTTPTransactions to be held back until the transport is replay-safe.
      
      Reviewed By: siyengar
      
      Differential Revision: D2974083
      
      fb-gh-sync-id: 037b14c24a80c828a25e483b6873a8e782af0cb4
      shipit-source-id: 037b14c24a80c828a25e483b6873a8e782af0cb4
      d00a7c52
    • Christopher Dykes's avatar
      Create the sys/stat.h portability header · 44af4e09
      Christopher Dykes authored
      Summary: Windows has it, but it doesn't define lstat, and a few other functions have other names.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3003096
      
      fb-gh-sync-id: e7bc210390d18806c8c89cbc18711bb7a728e12f
      shipit-source-id: e7bc210390d18806c8c89cbc18711bb7a728e12f
      44af4e09
    • Kyle Nekritz's avatar
      Make Bits.h respect FOLLY_HAVE_UNALIGNED_ACCESS. · d7a2b20b
      Kyle Nekritz authored
      Summary: This was causing a bunch of SIGBUS's on ARM platforms.
      
      Reviewed By: yfeldblum, mzlee
      
      Differential Revision: D3013458
      
      fb-gh-sync-id: 6d3f60c3f59d16cd3454e3a4231b967e5378724a
      shipit-source-id: 6d3f60c3f59d16cd3454e3a4231b967e5378724a
      d7a2b20b
    • Anirudh Ramachandran's avatar
      SSL cleanup: moving some OpenSSL definitions to new dir folly/io/async/ssl · 4700a31c
      Anirudh Ramachandran authored
      Summary:SSLContext and AsyncSSLSocket are growing with a lot of code that is
      OpenSSL-specific, and it may be good to refactor some of these before it gets
      out of hand.
      
      This is also useful to reduce complexity as we some additional features such as ServerHello parsing and TLS Cached Info (D2936570)
      
      Main changes:
       * Created a subdirectory folly/io/async/ssl to refactor code from folly/io/async. We may want to consider moving this out of folly/io/async
       * Moved OpenSSLPtrTypes.h to folly/io/async/ssl/OpenSSLPtrTypes.h
       * Moved 'OpenSSLUtils' from SSLContext to separate file OpenSSLUtils.{h,cpp}
       * Moved TLSExtensions and ClientHelloInfo from AsyncSSLSocket to TLSDefinitions.h
      
      Reviewed By: siyengar
      
      Differential Revision: D2978707
      
      fb-gh-sync-id: a21f02947aeffccc447da2124a91cc99315df1c7
      shipit-source-id: a21f02947aeffccc447da2124a91cc99315df1c7
      4700a31c
  8. 07 Mar, 2016 3 commits
    • Nathan Bronson's avatar
      minor tweak to MicroLock slow path · e756d07c
      Nathan Bronson authored
      Summary:This diff uses the x86 "pause" instruction or its equivalent when
      spinning in the MicroLock slow loop.  This gives a hint to the processor
      that it should devote more resources to the other execution contexts
      sharing the same core.  This diff also removes an mfence on x86 by using
      a slightly stronger memory model on the preceding compare_exchange_weak,
      and switches to a more portable way of invoking sched_yield().
      
      Reviewed By: dcolascione
      
      Differential Revision: D3018568
      
      fb-gh-sync-id: 02e0ab3a9d9bb9901eddf54e45b71cbb7758a227
      shipit-source-id: 02e0ab3a9d9bb9901eddf54e45b71cbb7758a227
      e756d07c
    • Giuseppe Ottaviano's avatar
      Deprecate dynamic::dynamic(std::initializer_list<dynamic>) · 07dc3ce5
      Giuseppe Ottaviano authored
      Summary:After DR95 the single braces dispatch to the copy constructor
      (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1467),
      so it is not possible anymore to initialize a singleton dynamic array
      using the braces syntax. The initializer list constructor already had
      a special case for empty lists, which unconditionally called the
      default constructor if defined.
      
      This diff deprecates the braces syntax and defines the following alternative:
      ```
      dynamic empty = dynamic::array;
      dynamic a = dynamic::array(1, 2, "foo");
      ```
      
      Reviewed By: luciang, yfeldblum
      
      Differential Revision: D3013423
      
      fb-gh-sync-id: a0cf09dfd96e9806044f7c3bf3592c637a9bc932
      shipit-source-id: a0cf09dfd96e9806044f7c3bf3592c637a9bc932
      07dc3ce5
    • Michael Lee's avatar
      Guard Getcpu in test. · b873a628
      Michael Lee authored
      Summary:Guarding this the same way it is done in
      detail/CacheLocality.cpp
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3013288
      
      fb-gh-sync-id: a1cc65cccc5cdf32339a739853c27a11ecd98ba0
      shipit-source-id: a1cc65cccc5cdf32339a739853c27a11ecd98ba0
      b873a628
  9. 05 Mar, 2016 3 commits
    • Christopher Dykes's avatar
      Create the Windows portability header · f3605199
      Christopher Dykes authored
      Summary: Because Windows' defines seem to get in the way more than they help.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2989507
      
      fb-gh-sync-id: 148f390ef6adf977bffa2262aa76839b2bf4f507
      shipit-source-id: 148f390ef6adf977bffa2262aa76839b2bf4f507
      f3605199
    • Yedidya Feldblum's avatar
      A warning for the portability headers · 22a8195e
      Yedidya Feldblum authored
      Summary: [Folly] A warning for the `portability` headers.
      
      Reviewed By: mzlee, Orvid, meyering
      
      Differential Revision: D3014442
      
      fb-gh-sync-id: f6557d8021dc2a50a656685492d717fdbff1124a
      shipit-source-id: f6557d8021dc2a50a656685492d717fdbff1124a
      22a8195e
    • Michael Lee's avatar
      Switch from tmpdir to TemporaryDirectory · 61f94b61
      Michael Lee authored
      Summary: tmpdir does not work on all platforms. TemporaryDirectory is more robust.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3013866
      
      fb-gh-sync-id: 51e2b7ec2348eb95b99c125a27bb2aca2b87ac21
      shipit-source-id: 51e2b7ec2348eb95b99c125a27bb2aca2b87ac21
      61f94b61
  10. 04 Mar, 2016 9 commits
    • Christopher Dykes's avatar
      Create the sys/types.h portability header · 30ec44d3
      Christopher Dykes authored
      Summary: Windows has it, but it doesn't define pid_t. It also doesn't define ssize_t, and it's not worth a separate header for a single typedef, so define it here as well.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3001168
      
      fb-gh-sync-id: 3722270181c200bbcf39043960f81609c854b132
      shipit-source-id: 3722270181c200bbcf39043960f81609c854b132
      30ec44d3
    • Max Warsewa's avatar
      Fix clang build for MicroLock · 2f595596
      Max Warsewa authored
      Summary: clang would complain about losing integer precision. Use unsigned for offset calculation.
      
      Reviewed By: luciang
      
      Differential Revision: D3011253
      
      fb-gh-sync-id: 10cb603708a22bf0e57f41b2486ffca4f5bf7a14
      shipit-source-id: 10cb603708a22bf0e57f41b2486ffca4f5bf7a14
      2f595596
    • Kyle Nekritz's avatar
      Add replay safety method and callback to AsyncTransport. · cb8456bd
      Kyle Nekritz authored
      Summary: This allows the transport to signal to a higher layer when it has become replay-safe.
      
      Reviewed By: siyengar
      
      Differential Revision: D2974057
      
      fb-gh-sync-id: 436f0c66b78f72ad34cdf4fe117771ea96b4388b
      shipit-source-id: 436f0c66b78f72ad34cdf4fe117771ea96b4388b
      cb8456bd
    • Michael Lee's avatar
      Make the test portable for different libc · 38b778b1
      Michael Lee authored
      Summary:The class name for std::runtime_erorr is sometimes
      St13runtime_error instead. And there is simlar mapping for other
      classes.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3013228
      
      fb-gh-sync-id: 6a162de348eeaa51c059f9619e25ecf051615bfc
      shipit-source-id: 6a162de348eeaa51c059f9619e25ecf051615bfc
      38b778b1
    • Yang Chi's avatar
      fix liger contbuild: cast offset_bytes to unsigned · e5ea40ea
      Yang Chi authored
      Summary: Apparently I don't know what I'm doing. But given lock_ is 8bit and the assert, I suppose cast offset_bytes to unsigned is safe.
      
      Reviewed By: dcolascione
      
      Differential Revision: D3010732
      
      fb-gh-sync-id: 1f3440a72d2f0b2fb145ab36966f0382a3009e0c
      shipit-source-id: 1f3440a72d2f0b2fb145ab36966f0382a3009e0c
      e5ea40ea
    • Yang Chi's avatar
      Remove persistentCork in native land · 3edc6278
      Yang Chi authored
      Summary: Remove persistent cork
      
      Reviewed By: francis-ma
      
      Differential Revision: D3008550
      
      fb-gh-sync-id: a5ce492876d98d74f5669c5ec5ff3486c0cb0b2c
      shipit-source-id: a5ce492876d98d74f5669c5ec5ff3486c0cb0b2c
      3edc6278
    • Den Raskovalov's avatar
      Add a missed glog header. · 320b5b76
      Den Raskovalov authored
      Summary: Instructions.h depends on glog/logging.h because of DCHECK_GT macros.
      
      Reviewed By: ot
      
      Differential Revision: D3009084
      
      fb-gh-sync-id: 05012e635a8c623ca1e653cc41a460778942c39e
      shipit-source-id: 05012e635a8c623ca1e653cc41a460778942c39e
      320b5b76
    • Daniel Colascione's avatar
      Add MicroLock as an alternative to MicroSpinLock · ed14d607
      Daniel Colascione authored
      Summary:MicroLock is a full-featured lock that fills the niche that
      MicroSpinLock and PicoSpinLock currently inhabit.  Unlike these two
      classes, MicroLock is a sleeping lock.  MicroLock requires two bits of
      a single word and has no particular alignment requirements.
      
      Reviewed By: ot
      
      Differential Revision: D3004474
      
      fb-gh-sync-id: a9bd28bd3f48e894d5bff407612ee4b228466209
      shipit-source-id: a9bd28bd3f48e894d5bff407612ee4b228466209
      ed14d607
    • Michael Lee's avatar
      Have internal tests use folly::Random instead of rand_r · a1b77701
      Michael Lee authored
      Summary: rand_r is not provided on all platforms, so use `folly::Random` instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3000351
      
      fb-gh-sync-id: 45df3e1957c4b529ab2d2cb4db13b71d13dcef5d
      shipit-source-id: 45df3e1957c4b529ab2d2cb4db13b71d13dcef5d
      a1b77701
  11. 03 Mar, 2016 5 commits
    • Marcelo Juchem's avatar
      Adding DynamicConverter support for enums · 863a22ad
      Marcelo Juchem authored
      Summary:DynamicConverter doesn't currently support reading enums.
      This diff addresses that by adding an enum specialization that uses integers as its underlying implementation.
      A follow-up is to handle both integers and strings, but that would require a way to parse strings into enums like Thrift static reflection provides (see https://github.com/facebook/fbthrift/blob/d17b072daddbd318f9afaa5562100eaba0f890e3/thrift/lib/cpp2/fatal/folly_dynamic-inl.h#L88,L92.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3002569
      
      fb-gh-sync-id: 27bf4a9d5a7844762f5311e2c777606a0e7753f0
      shipit-source-id: 27bf4a9d5a7844762f5311e2c777606a0e7753f0
      863a22ad
    • Michael Lee's avatar
      Fix printing of uint64_t in ConvTest · 6a7158dc
      Michael Lee authored
      Summary:uint64_t is an unsigned long for 64-bit, but a long long int
      for 32-bit.  `%lu` can cause truncation in certain implementations of
      libc.
      
      Reviewed By: ngoyal
      
      Differential Revision: D3007568
      
      fb-gh-sync-id: bbb1896c9727cbff413ac73ff0caa12bae5d8a6a
      shipit-source-id: bbb1896c9727cbff413ac73ff0caa12bae5d8a6a
      6a7158dc
    • Neel Goyal's avatar
      Add service identity to SSL socket and use in ticket cache · 41e2f6d4
      Neel Goyal authored
      Summary:Allow applications to specify a service identity tied to an SSLSocket
      that can be used as a ticket cache key.
      
      Further, add the cache key to the SSL_SESSION object and serialize it.
      
      Reviewed By: siyengar
      
      Differential Revision: D2991005
      
      fb-gh-sync-id: 25a5ddbb66bd9da2084159136cbe4d55b9e00f28
      shipit-source-id: 25a5ddbb66bd9da2084159136cbe4d55b9e00f28
      41e2f6d4
    • Kyle Nekritz's avatar
      Use false start with ALPN. · c85159a3
      Kyle Nekritz authored
      Summary: All the work we do in SSLContext to check the cipher and NPN usage is actually completely unnecessary since OpenSSL internally checks the cipher and use of ALPN/NPN after you set the SSL_MODE option (see `ssl3_can_cutthrough()` in ssl_lib.c). This just sets the option on the SSLContext instead.
      
      Reviewed By: siyengar
      
      Differential Revision: D3002063
      
      fb-gh-sync-id: 4514faf9ed2eb42a6e41d9e682b2c8aa52c46691
      shipit-source-id: 4514faf9ed2eb42a6e41d9e682b2c8aa52c46691
      c85159a3
    • Kyle Nekritz's avatar
      Fix AsyncSSLSocket handshake error reporting. · 4e0e47bb
      Kyle Nekritz authored
      Summary:https://www.openssl.org/docs/manmaster/ssl/SSL_get_error.html
      OpenSSL errors are a pain to deal with and we were handling several cases
      incorrectly, resulting in a ton of "DH lib" errors when none were likely
      actually DH lib errors.
      
      Reviewed By: siyengar
      
      Differential Revision: D2999084
      
      fb-gh-sync-id: b3182be2c199f79ed341af7dbf7524197a838584
      shipit-source-id: b3182be2c199f79ed341af7dbf7524197a838584
      4e0e47bb
  12. 02 Mar, 2016 5 commits
    • Christopher Dykes's avatar
      Create the strings.h portability header · 4f782bbf
      Christopher Dykes authored
      Summary: Windows doesn't have it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2990219
      
      fb-gh-sync-id: e9fe96905ec415874f0e2732b0685f3e7ad5d018
      shipit-source-id: e9fe96905ec415874f0e2732b0685f3e7ad5d018
      4f782bbf
    • Michael Lee's avatar
      Android does not always provide posix_memalign · b99ed996
      Michael Lee authored
      Summary: We could provide `posix_memalign` instead as part of portability, but I am not sure how to tell whether or not it will be available.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2991432
      
      fb-gh-sync-id: 587314d43779f3b8fead2c41ed05016e6350f2ee
      shipit-source-id: 587314d43779f3b8fead2c41ed05016e6350f2ee
      b99ed996
    • Daniel Colascione's avatar
      Improve RWSpinLock.h cautionary comment · ab442ee8
      Daniel Colascione authored
      Reviewed By: yfeldblum
      
      Differential Revision: D2998122
      
      fb-gh-sync-id: a113ba1a474da8a46052091acadb90c95d3c0c28
      shipit-source-id: a113ba1a474da8a46052091acadb90c95d3c0c28
      ab442ee8
    • Michael Lee's avatar
      i386 -fPIC requires `%ebx` · 3d90e863
      Michael Lee authored
      Summary:On i368 (until, I'm lead to believe i686) `%ebx` is used for the PIC register. Thus, when we use cpuid, we clobber that register and gcc loudly complains:
      
        folly/CpuId.h: In member function 'virtual void CpuId_Simple_Test::TestBody()':
        folly/CpuId.h:67:61: error: PIC register clobbered by 'ebx' in 'asm'
             __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "edx", "ecx");
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2991229
      
      fb-gh-sync-id: ee8795e36a4c173147d61e26c9590ec5da1d02b5
      shipit-source-id: ee8795e36a4c173147d61e26c9590ec5da1d02b5
      3d90e863
    • Christopher Dykes's avatar
      Create the portability header for time.h · 76344f7b
      Christopher Dykes authored
      Summary: Although MSVC does have time.h, and does have equivelents of these functions, those have slightly different semantics so we have to wrap them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2983613
      
      fb-gh-sync-id: 676cd524ffa834a4250a2acc76aa1200eefe62cc
      shipit-source-id: 676cd524ffa834a4250a2acc76aa1200eefe62cc
      76344f7b