Skip to content

Commit ef5ff12

Browse files
Even Rouault reformatting botrouault
authored andcommitted
Apply .clang-format to port
1 parent e8d930b commit ef5ff12

File tree

135 files changed

+32050
-30760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+32050
-30760
lines changed

port/cpl_alibaba_oss.cpp

Lines changed: 157 additions & 152 deletions
Large diffs are not rendered by default.

port/cpl_alibaba_oss.h

Lines changed: 81 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -43,83 +43,100 @@
4343
#include <map>
4444
#include "cpl_aws.h"
4545

46-
class VSIOSSHandleHelper final: public IVSIS3LikeHandleHelper
46+
class VSIOSSHandleHelper final : public IVSIS3LikeHandleHelper
4747
{
48-
CPL_DISALLOW_COPY_ASSIGN(VSIOSSHandleHelper)
48+
CPL_DISALLOW_COPY_ASSIGN(VSIOSSHandleHelper)
4949

50-
CPLString m_osURL{};
51-
CPLString m_osSecretAccessKey{};
52-
CPLString m_osAccessKeyId{};
53-
CPLString m_osEndpoint{};
54-
CPLString m_osBucket{};
55-
CPLString m_osObjectKey{};
56-
bool m_bUseHTTPS = false;
57-
bool m_bUseVirtualHosting = false;
50+
CPLString m_osURL{};
51+
CPLString m_osSecretAccessKey{};
52+
CPLString m_osAccessKeyId{};
53+
CPLString m_osEndpoint{};
54+
CPLString m_osBucket{};
55+
CPLString m_osObjectKey{};
56+
bool m_bUseHTTPS = false;
57+
bool m_bUseVirtualHosting = false;
5858

59-
void RebuildURL() override;
59+
void RebuildURL() override;
6060

61-
static bool GetConfiguration(const std::string& osPathForOption,
62-
CSLConstList papszOptions,
63-
CPLString& osSecretAccessKey,
64-
CPLString& osAccessKeyId);
61+
static bool GetConfiguration(const std::string &osPathForOption,
62+
CSLConstList papszOptions,
63+
CPLString &osSecretAccessKey,
64+
CPLString &osAccessKeyId);
6565

6666
protected:
67-
68-
public:
69-
VSIOSSHandleHelper(const CPLString& osSecretAccessKey,
70-
const CPLString& osAccessKeyId,
71-
const CPLString& osEndpoint,
72-
const CPLString& osBucket,
73-
const CPLString& osObjectKey,
74-
bool bUseHTTPS, bool bUseVirtualHosting);
75-
~VSIOSSHandleHelper();
76-
77-
static VSIOSSHandleHelper* BuildFromURI(const char* pszURI,
78-
const char* pszFSPrefix,
79-
bool bAllowNoObject,
80-
CSLConstList papszOptions = nullptr);
81-
static CPLString BuildURL(const CPLString& osEndpoint,
82-
const CPLString& osBucket,
83-
const CPLString& osObjectKey,
84-
bool bUseHTTPS, bool bUseVirtualHosting);
85-
86-
struct curl_slist* GetCurlHeaders(
87-
const CPLString& osVerb,
88-
const struct curl_slist* psExistingHeaders,
89-
const void *pabyDataContent = nullptr,
90-
size_t nBytesContent = 0 ) const override;
91-
92-
bool CanRestartOnError(const char*, const char* pszHeaders,
93-
bool bSetError,
94-
bool* pbUpdateMap = nullptr) override;
95-
96-
const CPLString& GetURL() const override { return m_osURL; }
97-
const CPLString& GetBucket() const { return m_osBucket; }
98-
const CPLString& GetObjectKey() const { return m_osObjectKey; }
99-
const CPLString& GetEndpoint()const { return m_osEndpoint; }
100-
bool GetVirtualHosting() const { return m_bUseVirtualHosting; }
101-
102-
CPLString GetCopySourceHeader() const override { return "x-oss-copy-source"; }
103-
104-
void SetEndpoint(const CPLString &osStr);
105-
void SetVirtualHosting(bool b);
106-
107-
CPLString GetSignedURL(CSLConstList papszOptions);
67+
public:
68+
VSIOSSHandleHelper(const CPLString &osSecretAccessKey,
69+
const CPLString &osAccessKeyId,
70+
const CPLString &osEndpoint, const CPLString &osBucket,
71+
const CPLString &osObjectKey, bool bUseHTTPS,
72+
bool bUseVirtualHosting);
73+
~VSIOSSHandleHelper();
74+
75+
static VSIOSSHandleHelper *
76+
BuildFromURI(const char *pszURI, const char *pszFSPrefix,
77+
bool bAllowNoObject, CSLConstList papszOptions = nullptr);
78+
static CPLString BuildURL(const CPLString &osEndpoint,
79+
const CPLString &osBucket,
80+
const CPLString &osObjectKey, bool bUseHTTPS,
81+
bool bUseVirtualHosting);
82+
83+
struct curl_slist *
84+
GetCurlHeaders(const CPLString &osVerb,
85+
const struct curl_slist *psExistingHeaders,
86+
const void *pabyDataContent = nullptr,
87+
size_t nBytesContent = 0) const override;
88+
89+
bool CanRestartOnError(const char *, const char *pszHeaders, bool bSetError,
90+
bool *pbUpdateMap = nullptr) override;
91+
92+
const CPLString &GetURL() const override
93+
{
94+
return m_osURL;
95+
}
96+
const CPLString &GetBucket() const
97+
{
98+
return m_osBucket;
99+
}
100+
const CPLString &GetObjectKey() const
101+
{
102+
return m_osObjectKey;
103+
}
104+
const CPLString &GetEndpoint() const
105+
{
106+
return m_osEndpoint;
107+
}
108+
bool GetVirtualHosting() const
109+
{
110+
return m_bUseVirtualHosting;
111+
}
112+
113+
CPLString GetCopySourceHeader() const override
114+
{
115+
return "x-oss-copy-source";
116+
}
117+
118+
void SetEndpoint(const CPLString &osStr);
119+
void SetVirtualHosting(bool b);
120+
121+
CPLString GetSignedURL(CSLConstList papszOptions);
108122
};
109123

110124
class VSIOSSUpdateParams
111125
{
112-
public:
113-
CPLString m_osEndpoint{};
126+
public:
127+
CPLString m_osEndpoint{};
114128

115-
VSIOSSUpdateParams() = default;
129+
VSIOSSUpdateParams() = default;
116130

117-
explicit VSIOSSUpdateParams(const VSIOSSHandleHelper* poHelper) :
118-
m_osEndpoint(poHelper->GetEndpoint()) {}
131+
explicit VSIOSSUpdateParams(const VSIOSSHandleHelper *poHelper)
132+
: m_osEndpoint(poHelper->GetEndpoint())
133+
{
134+
}
119135

120-
void UpdateHandlerHelper(VSIOSSHandleHelper* poHelper) {
121-
poHelper->SetEndpoint(m_osEndpoint);
122-
}
136+
void UpdateHandlerHelper(VSIOSSHandleHelper *poHelper)
137+
{
138+
poHelper->SetEndpoint(m_osEndpoint);
139+
}
123140
};
124141

125142
#endif /* HAVE_CURL */

port/cpl_atomic_ops.cpp

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,59 +33,59 @@
3333

3434
// TODO: If C++11, use #include <atomic>.
3535

36-
3736
#if defined(_MSC_VER)
3837

3938
#include <windows.h>
4039

41-
int CPLAtomicAdd(volatile int* ptr, int increment)
40+
int CPLAtomicAdd(volatile int *ptr, int increment)
4241
{
43-
return InterlockedExchangeAdd((volatile LONG*)(ptr),
44-
(LONG)(increment)) + increment;
42+
return InterlockedExchangeAdd((volatile LONG *)(ptr), (LONG)(increment)) +
43+
increment;
4544
}
4645

47-
int CPLAtomicCompareAndExchange(volatile int* ptr, int oldval, int newval)
46+
int CPLAtomicCompareAndExchange(volatile int *ptr, int oldval, int newval)
4847
{
49-
return (LONG)InterlockedCompareExchange((volatile LONG*)(ptr), (LONG)newval,
50-
(LONG)oldval) == (LONG)oldval;
48+
return (LONG)InterlockedCompareExchange((volatile LONG *)(ptr),
49+
(LONG)newval,
50+
(LONG)oldval) == (LONG)oldval;
5151
}
5252

5353
#elif defined(__MINGW32__) && defined(__i386__)
5454

5555
#include <windows.h>
5656

57-
int CPLAtomicAdd(volatile int* ptr, int increment)
57+
int CPLAtomicAdd(volatile int *ptr, int increment)
5858
{
59-
return InterlockedExchangeAdd((LONG*)(ptr), (LONG)(increment)) + increment;
59+
return InterlockedExchangeAdd((LONG *)(ptr), (LONG)(increment)) + increment;
6060
}
6161

62-
int CPLAtomicCompareAndExchange(volatile int* ptr, int oldval, int newval)
62+
int CPLAtomicCompareAndExchange(volatile int *ptr, int oldval, int newval)
6363
{
64-
return (LONG)InterlockedCompareExchange((LONG*)(ptr), (LONG)newval,
65-
(LONG)oldval) == (LONG)oldval;
64+
return (LONG)InterlockedCompareExchange((LONG *)(ptr), (LONG)newval,
65+
(LONG)oldval) == (LONG)oldval;
6666
}
6767

6868
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
6969

70-
int CPLAtomicAdd(volatile int* ptr, int increment)
70+
int CPLAtomicAdd(volatile int *ptr, int increment)
7171
{
72-
int temp = increment;
73-
__asm__ __volatile__("lock; xaddl %0,%1"
74-
: "+r" (temp), "+m" (*ptr)
75-
: : "memory");
76-
return temp + increment;
72+
int temp = increment;
73+
__asm__ __volatile__("lock; xaddl %0,%1"
74+
: "+r"(temp), "+m"(*ptr)
75+
:
76+
: "memory");
77+
return temp + increment;
7778
}
7879

79-
int CPLAtomicCompareAndExchange(volatile int* ptr, int oldval, int newval)
80+
int CPLAtomicCompareAndExchange(volatile int *ptr, int oldval, int newval)
8081
{
8182
unsigned char ret;
8283

83-
__asm__ __volatile__ (
84-
" lock; cmpxchgl %2,%1\n"
85-
" sete %0\n"
86-
: "=q" (ret), "=m" (*ptr)
87-
: "r" (newval), "m" (*ptr), "a" (oldval)
88-
: "memory");
84+
__asm__ __volatile__(" lock; cmpxchgl %2,%1\n"
85+
" sete %0\n"
86+
: "=q"(ret), "=m"(*ptr)
87+
: "r"(newval), "m"(*ptr), "a"(oldval)
88+
: "memory");
8989

9090
return static_cast<int>(ret);
9191
}
@@ -97,46 +97,46 @@ int CPLAtomicCompareAndExchange(volatile int* ptr, int oldval, int newval)
9797
// We use a ./configure test to determine whether this builtins are available.
9898
// as it appears that the GCC 4.1 version used on debian etch is broken when
9999
// linking such instructions.
100-
int CPLAtomicAdd( volatile int* ptr, int increment )
100+
int CPLAtomicAdd(volatile int *ptr, int increment)
101101
{
102-
if( increment > 0 )
103-
return __sync_add_and_fetch(ptr, increment);
102+
if (increment > 0)
103+
return __sync_add_and_fetch(ptr, increment);
104104

105-
return __sync_sub_and_fetch(ptr, -increment);
105+
return __sync_sub_and_fetch(ptr, -increment);
106106
}
107107

108-
int CPLAtomicCompareAndExchange( volatile int* ptr, int oldval, int newval )
108+
int CPLAtomicCompareAndExchange(volatile int *ptr, int oldval, int newval)
109109
{
110-
return __sync_bool_compare_and_swap (ptr, oldval, newval);
110+
return __sync_bool_compare_and_swap(ptr, oldval, newval);
111111
}
112112

113113
#elif defined(__MACH__) && defined(__APPLE__)
114114

115115
#include <libkern/OSAtomic.h>
116116

117-
int CPLAtomicAdd(volatile int* ptr, int increment)
117+
int CPLAtomicAdd(volatile int *ptr, int increment)
118118
{
119-
return OSAtomicAdd32(increment, (int*)(ptr));
119+
return OSAtomicAdd32(increment, (int *)(ptr));
120120
}
121121

122-
int CPLAtomicCompareAndExchange(volatile int* ptr, int oldval, int newval)
122+
int CPLAtomicCompareAndExchange(volatile int *ptr, int oldval, int newval)
123123
{
124-
return OSAtomicCompareAndSwap32(oldval, newval, (int*)(ptr));
124+
return OSAtomicCompareAndSwap32(oldval, newval, (int *)(ptr));
125125
}
126126

127127
#elif !defined(CPL_MULTIPROC_PTHREAD)
128128
#warning "Needs real lock API to implement properly atomic increment"
129129

130130
// Dummy implementation.
131-
int CPLAtomicAdd(volatile int* ptr, int increment)
131+
int CPLAtomicAdd(volatile int *ptr, int increment)
132132
{
133133
(*ptr) += increment;
134134
return *ptr;
135135
}
136136

137-
int CPLAtomicCompareAndExchange( volatile int* ptr, int oldval, int newval )
137+
int CPLAtomicCompareAndExchange(volatile int *ptr, int oldval, int newval)
138138
{
139-
if( *ptr == oldval )
139+
if (*ptr == oldval)
140140
{
141141
*ptr = newval;
142142
return TRUE;
@@ -151,17 +151,17 @@ int CPLAtomicCompareAndExchange( volatile int* ptr, int oldval, int newval )
151151
static CPLLock *hAtomicOpLock = nullptr;
152152

153153
// Slow, but safe, implementation using a mutex.
154-
int CPLAtomicAdd(volatile int* ptr, int increment)
154+
int CPLAtomicAdd(volatile int *ptr, int increment)
155155
{
156156
CPLLockHolderD(&hAtomicOpLock, LOCK_SPIN);
157157
(*ptr) += increment;
158158
return *ptr;
159159
}
160160

161-
int CPLAtomicCompareAndExchange(volatile int* ptr, int oldval, int newval)
161+
int CPLAtomicCompareAndExchange(volatile int *ptr, int oldval, int newval)
162162
{
163163
CPLLockHolderD(&hAtomicOpLock, LOCK_SPIN);
164-
if( *ptr == oldval )
164+
if (*ptr == oldval)
165165
{
166166
*ptr = newval;
167167
return TRUE;

0 commit comments

Comments
 (0)