We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
update bundled zstd code
we have 1.3.4 bundled, current see there: https://github.com/facebook/zstd/releases

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup_zstd.py`
Content:
```
1 # Support code for building a C extension with zstd files
2 #
3 # Copyright (c) 2016-present, Gregory Szorc
4 #               2017-present, Thomas Waldmann (mods to make it more generic)
5 # All rights reserved.
6 #
7 # This software may be modified and distributed under the terms
8 # of the BSD license. See the LICENSE file for details.
9 
10 import os
11 
12 # zstd files, structure as seen in zstd project repository:
13 
14 zstd_sources = [
15     'lib/common/entropy_common.c',
16     'lib/common/error_private.c',
17     'lib/common/fse_decompress.c',
18     'lib/common/pool.c',
19     'lib/common/threading.c',
20     'lib/common/xxhash.c',
21     'lib/common/zstd_common.c',
22     'lib/compress/fse_compress.c',
23     'lib/compress/huf_compress.c',
24     'lib/compress/zstd_compress.c',
25     'lib/compress/zstd_double_fast.c',
26     'lib/compress/zstd_fast.c',
27     'lib/compress/zstd_lazy.c',
28     'lib/compress/zstd_ldm.c',
29     'lib/compress/zstd_opt.c',
30     'lib/compress/zstdmt_compress.c',
31     'lib/decompress/huf_decompress.c',
32     'lib/decompress/zstd_decompress.c',
33     'lib/dictBuilder/cover.c',
34     'lib/dictBuilder/divsufsort.c',
35     'lib/dictBuilder/zdict.c',
36 ]
37 
38 zstd_sources_legacy = [
39     'lib/deprecated/zbuff_common.c',
40     'lib/deprecated/zbuff_compress.c',
41     'lib/deprecated/zbuff_decompress.c',
42     'lib/legacy/zstd_v01.c',
43     'lib/legacy/zstd_v02.c',
44     'lib/legacy/zstd_v03.c',
45     'lib/legacy/zstd_v04.c',
46     'lib/legacy/zstd_v05.c',
47     'lib/legacy/zstd_v06.c',
48     'lib/legacy/zstd_v07.c',
49 ]
50 
51 zstd_includes = [
52     'lib',
53     'lib/common',
54     'lib/compress',
55     'lib/decompress',
56     'lib/dictBuilder',
57 ]
58 
59 zstd_includes_legacy = [
60     'lib/deprecated',
61     'lib/legacy',
62 ]
63 
64 
65 def zstd_system_prefix(prefixes):
66     for prefix in prefixes:
67         filename = os.path.join(prefix, 'include', 'zstd.h')
68         if os.path.exists(filename):
69             with open(filename, 'rb') as fd:
70                 if b'ZSTD_getFrameContentSize' in fd.read():  # checks for zstd >= 1.3.0
71                     return prefix
72 
73 
74 def zstd_ext_kwargs(bundled_path, system_prefix=None, system=False, multithreaded=False, legacy=False, **kwargs):
75     """amend kwargs with zstd suff for a distutils.extension.Extension initialization.
76 
77     bundled_path: relative (to this file) path to the bundled library source code files
78     system_prefix: where the system-installed library can be found
79     system: True: use the system-installed shared library, False: use the bundled library code
80     multithreaded: True: define ZSTD_MULTITHREAD
81     legacy: include legacy API support
82     kwargs: distutils.extension.Extension kwargs that should be amended
83     returns: amended kwargs
84     """
85     def multi_join(paths, *path_segments):
86         """apply os.path.join on a list of paths"""
87         return [os.path.join(*(path_segments + (path, ))) for path in paths]
88 
89     use_system = system and system_prefix is not None
90 
91     sources = kwargs.get('sources', [])
92     if not use_system:
93         sources += multi_join(zstd_sources, bundled_path)
94         if legacy:
95             sources += multi_join(zstd_sources_legacy, bundled_path)
96 
97     include_dirs = kwargs.get('include_dirs', [])
98     if use_system:
99         include_dirs += multi_join(['include'], system_prefix)
100     else:
101         include_dirs += multi_join(zstd_includes, bundled_path)
102         if legacy:
103             include_dirs += multi_join(zstd_includes_legacy, bundled_path)
104 
105     library_dirs = kwargs.get('library_dirs', [])
106     if use_system:
107         library_dirs += multi_join(['lib'], system_prefix)
108 
109     libraries = kwargs.get('libraries', [])
110     if use_system:
111         libraries += ['zstd', ]
112 
113     extra_compile_args = kwargs.get('extra_compile_args', [])
114     if multithreaded:
115         extra_compile_args += ['-DZSTD_MULTITHREAD', ]
116     if not use_system:
117         extra_compile_args += ['-DZSTDLIB_VISIBILITY=', '-DZDICTLIB_VISIBILITY=', '-DZSTDERRORLIB_VISIBILITY=', ]
118                                # '-fvisibility=hidden' does not work, doesn't find PyInit_compress then
119         if legacy:
120             extra_compile_args += ['-DZSTD_LEGACY_SUPPORT=1', ]
121 
122     ret = dict(**kwargs)
123     ret.update(dict(sources=sources, extra_compile_args=extra_compile_args,
124                     include_dirs=include_dirs, library_dirs=library_dirs, libraries=libraries))
125     return ret
126
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setup_zstd.py b/setup_zstd.py
--- a/setup_zstd.py
+++ b/setup_zstd.py
@@ -12,6 +12,7 @@
 # zstd files, structure as seen in zstd project repository:
 
 zstd_sources = [
+    'lib/common/debug.c',
     'lib/common/entropy_common.c',
     'lib/common/error_private.c',
     'lib/common/fse_decompress.c',
@@ -20,6 +21,7 @@
     'lib/common/xxhash.c',
     'lib/common/zstd_common.c',
     'lib/compress/fse_compress.c',
+    'lib/compress/hist.c',
     'lib/compress/huf_compress.c',
     'lib/compress/zstd_compress.c',
     'lib/compress/zstd_double_fast.c',
@@ -29,9 +31,12 @@
     'lib/compress/zstd_opt.c',
     'lib/compress/zstdmt_compress.c',
     'lib/decompress/huf_decompress.c',
+    'lib/decompress/zstd_ddict.c',
     'lib/decompress/zstd_decompress.c',
+    'lib/decompress/zstd_decompress_block.c',
     'lib/dictBuilder/cover.c',
     'lib/dictBuilder/divsufsort.c',
+    'lib/dictBuilder/fastcover.c',
     'lib/dictBuilder/zdict.c',
 ]

{"golden_diff": "diff --git a/setup_zstd.py b/setup_zstd.py\n--- a/setup_zstd.py\n+++ b/setup_zstd.py\n@@ -12,6 +12,7 @@\n # zstd files, structure as seen in zstd project repository:\n \n zstd_sources = [\n+    'lib/common/debug.c',\n     'lib/common/entropy_common.c',\n     'lib/common/error_private.c',\n     'lib/common/fse_decompress.c',\n@@ -20,6 +21,7 @@\n     'lib/common/xxhash.c',\n     'lib/common/zstd_common.c',\n     'lib/compress/fse_compress.c',\n+    'lib/compress/hist.c',\n     'lib/compress/huf_compress.c',\n     'lib/compress/zstd_compress.c',\n     'lib/compress/zstd_double_fast.c',\n@@ -29,9 +31,12 @@\n     'lib/compress/zstd_opt.c',\n     'lib/compress/zstdmt_compress.c',\n     'lib/decompress/huf_decompress.c',\n+    'lib/decompress/zstd_ddict.c',\n     'lib/decompress/zstd_decompress.c',\n+    'lib/decompress/zstd_decompress_block.c',\n     'lib/dictBuilder/cover.c',\n     'lib/dictBuilder/divsufsort.c',\n+    'lib/dictBuilder/fastcover.c',\n     'lib/dictBuilder/zdict.c',\n ]\n", "issue": "update bundled zstd code\nwe have 1.3.4 bundled, current see there: https://github.com/facebook/zstd/releases\n", "before_files": [{"content": "# Support code for building a C extension with zstd files\n#\n# Copyright (c) 2016-present, Gregory Szorc\n#               2017-present, Thomas Waldmann (mods to make it more generic)\n# All rights reserved.\n#\n# This software may be modified and distributed under the terms\n# of the BSD license. See the LICENSE file for details.\n\nimport os\n\n# zstd files, structure as seen in zstd project repository:\n\nzstd_sources = [\n    'lib/common/entropy_common.c',\n    'lib/common/error_private.c',\n    'lib/common/fse_decompress.c',\n    'lib/common/pool.c',\n    'lib/common/threading.c',\n    'lib/common/xxhash.c',\n    'lib/common/zstd_common.c',\n    'lib/compress/fse_compress.c',\n    'lib/compress/huf_compress.c',\n    'lib/compress/zstd_compress.c',\n    'lib/compress/zstd_double_fast.c',\n    'lib/compress/zstd_fast.c',\n    'lib/compress/zstd_lazy.c',\n    'lib/compress/zstd_ldm.c',\n    'lib/compress/zstd_opt.c',\n    'lib/compress/zstdmt_compress.c',\n    'lib/decompress/huf_decompress.c',\n    'lib/decompress/zstd_decompress.c',\n    'lib/dictBuilder/cover.c',\n    'lib/dictBuilder/divsufsort.c',\n    'lib/dictBuilder/zdict.c',\n]\n\nzstd_sources_legacy = [\n    'lib/deprecated/zbuff_common.c',\n    'lib/deprecated/zbuff_compress.c',\n    'lib/deprecated/zbuff_decompress.c',\n    'lib/legacy/zstd_v01.c',\n    'lib/legacy/zstd_v02.c',\n    'lib/legacy/zstd_v03.c',\n    'lib/legacy/zstd_v04.c',\n    'lib/legacy/zstd_v05.c',\n    'lib/legacy/zstd_v06.c',\n    'lib/legacy/zstd_v07.c',\n]\n\nzstd_includes = [\n    'lib',\n    'lib/common',\n    'lib/compress',\n    'lib/decompress',\n    'lib/dictBuilder',\n]\n\nzstd_includes_legacy = [\n    'lib/deprecated',\n    'lib/legacy',\n]\n\n\ndef zstd_system_prefix(prefixes):\n    for prefix in prefixes:\n        filename = os.path.join(prefix, 'include', 'zstd.h')\n        if os.path.exists(filename):\n            with open(filename, 'rb') as fd:\n                if b'ZSTD_getFrameContentSize' in fd.read():  # checks for zstd >= 1.3.0\n                    return prefix\n\n\ndef zstd_ext_kwargs(bundled_path, system_prefix=None, system=False, multithreaded=False, legacy=False, **kwargs):\n    \"\"\"amend kwargs with zstd suff for a distutils.extension.Extension initialization.\n\n    bundled_path: relative (to this file) path to the bundled library source code files\n    system_prefix: where the system-installed library can be found\n    system: True: use the system-installed shared library, False: use the bundled library code\n    multithreaded: True: define ZSTD_MULTITHREAD\n    legacy: include legacy API support\n    kwargs: distutils.extension.Extension kwargs that should be amended\n    returns: amended kwargs\n    \"\"\"\n    def multi_join(paths, *path_segments):\n        \"\"\"apply os.path.join on a list of paths\"\"\"\n        return [os.path.join(*(path_segments + (path, ))) for path in paths]\n\n    use_system = system and system_prefix is not None\n\n    sources = kwargs.get('sources', [])\n    if not use_system:\n        sources += multi_join(zstd_sources, bundled_path)\n        if legacy:\n            sources += multi_join(zstd_sources_legacy, bundled_path)\n\n    include_dirs = kwargs.get('include_dirs', [])\n    if use_system:\n        include_dirs += multi_join(['include'], system_prefix)\n    else:\n        include_dirs += multi_join(zstd_includes, bundled_path)\n        if legacy:\n            include_dirs += multi_join(zstd_includes_legacy, bundled_path)\n\n    library_dirs = kwargs.get('library_dirs', [])\n    if use_system:\n        library_dirs += multi_join(['lib'], system_prefix)\n\n    libraries = kwargs.get('libraries', [])\n    if use_system:\n        libraries += ['zstd', ]\n\n    extra_compile_args = kwargs.get('extra_compile_args', [])\n    if multithreaded:\n        extra_compile_args += ['-DZSTD_MULTITHREAD', ]\n    if not use_system:\n        extra_compile_args += ['-DZSTDLIB_VISIBILITY=', '-DZDICTLIB_VISIBILITY=', '-DZSTDERRORLIB_VISIBILITY=', ]\n                               # '-fvisibility=hidden' does not work, doesn't find PyInit_compress then\n        if legacy:\n            extra_compile_args += ['-DZSTD_LEGACY_SUPPORT=1', ]\n\n    ret = dict(**kwargs)\n    ret.update(dict(sources=sources, extra_compile_args=extra_compile_args,\n                    include_dirs=include_dirs, library_dirs=library_dirs, libraries=libraries))\n    return ret\n", "path": "setup_zstd.py"}], "after_files": [{"content": "# Support code for building a C extension with zstd files\n#\n# Copyright (c) 2016-present, Gregory Szorc\n#               2017-present, Thomas Waldmann (mods to make it more generic)\n# All rights reserved.\n#\n# This software may be modified and distributed under the terms\n# of the BSD license. See the LICENSE file for details.\n\nimport os\n\n# zstd files, structure as seen in zstd project repository:\n\nzstd_sources = [\n    'lib/common/debug.c',\n    'lib/common/entropy_common.c',\n    'lib/common/error_private.c',\n    'lib/common/fse_decompress.c',\n    'lib/common/pool.c',\n    'lib/common/threading.c',\n    'lib/common/xxhash.c',\n    'lib/common/zstd_common.c',\n    'lib/compress/fse_compress.c',\n    'lib/compress/hist.c',\n    'lib/compress/huf_compress.c',\n    'lib/compress/zstd_compress.c',\n    'lib/compress/zstd_double_fast.c',\n    'lib/compress/zstd_fast.c',\n    'lib/compress/zstd_lazy.c',\n    'lib/compress/zstd_ldm.c',\n    'lib/compress/zstd_opt.c',\n    'lib/compress/zstdmt_compress.c',\n    'lib/decompress/huf_decompress.c',\n    'lib/decompress/zstd_ddict.c',\n    'lib/decompress/zstd_decompress.c',\n    'lib/decompress/zstd_decompress_block.c',\n    'lib/dictBuilder/cover.c',\n    'lib/dictBuilder/divsufsort.c',\n    'lib/dictBuilder/fastcover.c',\n    'lib/dictBuilder/zdict.c',\n]\n\nzstd_sources_legacy = [\n    'lib/deprecated/zbuff_common.c',\n    'lib/deprecated/zbuff_compress.c',\n    'lib/deprecated/zbuff_decompress.c',\n    'lib/legacy/zstd_v01.c',\n    'lib/legacy/zstd_v02.c',\n    'lib/legacy/zstd_v03.c',\n    'lib/legacy/zstd_v04.c',\n    'lib/legacy/zstd_v05.c',\n    'lib/legacy/zstd_v06.c',\n    'lib/legacy/zstd_v07.c',\n]\n\nzstd_includes = [\n    'lib',\n    'lib/common',\n    'lib/compress',\n    'lib/decompress',\n    'lib/dictBuilder',\n]\n\nzstd_includes_legacy = [\n    'lib/deprecated',\n    'lib/legacy',\n]\n\n\ndef zstd_system_prefix(prefixes):\n    for prefix in prefixes:\n        filename = os.path.join(prefix, 'include', 'zstd.h')\n        if os.path.exists(filename):\n            with open(filename, 'rb') as fd:\n                if b'ZSTD_getFrameContentSize' in fd.read():  # checks for zstd >= 1.3.0\n                    return prefix\n\n\ndef zstd_ext_kwargs(bundled_path, system_prefix=None, system=False, multithreaded=False, legacy=False, **kwargs):\n    \"\"\"amend kwargs with zstd suff for a distutils.extension.Extension initialization.\n\n    bundled_path: relative (to this file) path to the bundled library source code files\n    system_prefix: where the system-installed library can be found\n    system: True: use the system-installed shared library, False: use the bundled library code\n    multithreaded: True: define ZSTD_MULTITHREAD\n    legacy: include legacy API support\n    kwargs: distutils.extension.Extension kwargs that should be amended\n    returns: amended kwargs\n    \"\"\"\n    def multi_join(paths, *path_segments):\n        \"\"\"apply os.path.join on a list of paths\"\"\"\n        return [os.path.join(*(path_segments + (path, ))) for path in paths]\n\n    use_system = system and system_prefix is not None\n\n    sources = kwargs.get('sources', [])\n    if not use_system:\n        sources += multi_join(zstd_sources, bundled_path)\n        if legacy:\n            sources += multi_join(zstd_sources_legacy, bundled_path)\n\n    include_dirs = kwargs.get('include_dirs', [])\n    if use_system:\n        include_dirs += multi_join(['include'], system_prefix)\n    else:\n        include_dirs += multi_join(zstd_includes, bundled_path)\n        if legacy:\n            include_dirs += multi_join(zstd_includes_legacy, bundled_path)\n\n    library_dirs = kwargs.get('library_dirs', [])\n    if use_system:\n        library_dirs += multi_join(['lib'], system_prefix)\n\n    libraries = kwargs.get('libraries', [])\n    if use_system:\n        libraries += ['zstd', ]\n\n    extra_compile_args = kwargs.get('extra_compile_args', [])\n    if multithreaded:\n        extra_compile_args += ['-DZSTD_MULTITHREAD', ]\n    if not use_system:\n        extra_compile_args += ['-DZSTDLIB_VISIBILITY=', '-DZDICTLIB_VISIBILITY=', '-DZSTDERRORLIB_VISIBILITY=', ]\n                               # '-fvisibility=hidden' does not work, doesn't find PyInit_compress then\n        if legacy:\n            extra_compile_args += ['-DZSTD_LEGACY_SUPPORT=1', ]\n\n    ret = dict(**kwargs)\n    ret.update(dict(sources=sources, extra_compile_args=extra_compile_args,\n                    include_dirs=include_dirs, library_dirs=library_dirs, libraries=libraries))\n    return ret\n", "path": "setup_zstd.py"}]}