Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77f27d5

Browse files
committed
Fix some portability problems (get it to compile, at least, on HP's cc)
1 parentaa6970e commit77f27d5

File tree

5 files changed

+34
-41
lines changed

5 files changed

+34
-41
lines changed

‎contrib/pgcrypto/crypt-blowfish.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,15 @@
3030
* hadn't seen his code).
3131
*/
3232

33-
#include<postgres.h>
33+
#include"postgres.h"
34+
3435
#include"px-crypt.h"
3536
#define__set_errno(v)
3637

3738
#ifndef__set_errno
3839
#define__set_errno(val) errno = (val)
3940
#endif
4041

41-
#undef __CONST
42-
#ifdef__GNUC__
43-
#define__CONST __const
44-
#else
45-
#define__CONST
46-
#endif
47-
4842
#ifdef__i386__
4943
#defineBF_ASM0/* 1 */
5044
#defineBF_SCALE1
@@ -373,7 +367,7 @@ static unsigned char BF_atoi64[0x60] = {
373367
(dst) = tmp; \
374368
}
375369

376-
staticintBF_decode(BF_word*dst,__CONSTchar*src,intsize)
370+
staticintBF_decode(BF_word*dst,constchar*src,intsize)
377371
{
378372
unsignedchar*dptr= (unsignedchar*)dst;
379373
unsignedchar*end=dptr+size;
@@ -397,7 +391,7 @@ static int BF_decode(BF_word *dst, __CONST char *src, int size)
397391
return0;
398392
}
399393

400-
staticvoidBF_encode(char*dst,__CONSTBF_word*src,intsize)
394+
staticvoidBF_encode(char*dst,constBF_word*src,intsize)
401395
{
402396
unsignedchar*sptr= (unsignedchar*)src;
403397
unsignedchar*end=sptr+size;
@@ -536,9 +530,9 @@ extern void _BF_body_r(BF_ctx *ctx);
536530

537531
#endif
538532

539-
staticvoidBF_set_key(__CONSTchar*key,BF_keyexpanded,BF_keyinitial)
533+
staticvoidBF_set_key(constchar*key,BF_keyexpanded,BF_keyinitial)
540534
{
541-
__CONSTchar*ptr=key;
535+
constchar*ptr=key;
542536
inti,j;
543537
BF_wordtmp;
544538

@@ -556,7 +550,7 @@ static void BF_set_key(__CONST char *key, BF_key expanded, BF_key initial)
556550
}
557551
}
558552

559-
char*_crypt_blowfish_rn(__CONSTchar*key,__CONSTchar*setting,
553+
char*_crypt_blowfish_rn(constchar*key,constchar*setting,
560554
char*output,intsize)
561555
{
562556
struct {

‎contrib/pgcrypto/crypt-des.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,13 @@
5858
*alignment).
5959
*/
6060

61-
#include<postgres.h>
61+
#include"postgres.h"
62+
6263
#include"px-crypt.h"
6364

6465
/* for ntohl/htonl */
6566
#include<netinet/in.h>
6667

67-
68-
/* We can't always assume gcc */
69-
#ifdef__GNUC__
70-
#defineINLINE inline
71-
#endif
72-
7368
#define_PASSWORD_EFMT1 '_'
7469

7570
staticuint8IP[64]= {
@@ -200,7 +195,7 @@ static uint32 comp_maskl[8][128],
200195
staticuint32old_rawkey0,
201196
old_rawkey1;
202197

203-
staticINLINEint
198+
staticinlineint
204199
ascii_to_bin(charch)
205200
{
206201
if (ch>'z')
@@ -611,6 +606,7 @@ do_des(uint32 l_in, uint32 r_in, uint32 * l_out, uint32 * r_out, int count)
611606
staticint
612607
des_cipher(constchar*in,char*out,longsalt,intcount)
613608
{
609+
uint32buffer[2];
614610
uint32l_out,
615611
r_out,
616612
rawl,
@@ -622,13 +618,20 @@ des_cipher(const char *in, char *out, long salt, int count)
622618

623619
setup_salt(salt);
624620

625-
rawl=ntohl(*((uint32*)in)++);
626-
rawr=ntohl(*((uint32*)in));
621+
/* copy data to avoid assuming input is word-aligned */
622+
memcpy(buffer,in,sizeof(buffer));
623+
624+
rawl=ntohl(buffer[0]);
625+
rawr=ntohl(buffer[1]);
627626

628627
retval=do_des(rawl,rawr,&l_out,&r_out,count);
629628

630-
*((uint32*)out)++=htonl(l_out);
631-
*((uint32*)out)=htonl(r_out);
629+
buffer[0]=htonl(l_out);
630+
buffer[1]=htonl(r_out);
631+
632+
/* copy data to avoid assuming output is word-aligned */
633+
memcpy(out,buffer,sizeof(buffer));
634+
632635
return (retval);
633636
}
634637

‎contrib/pgcrypto/crypt-gensalt.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@
1010
* may not be compiled always. -- marko
1111
*/
1212

13-
#include<postgres.h>
13+
#include"postgres.h"
14+
1415
#include"px-crypt.h"
1516

1617
#include<errno.h>
1718
#ifndef__set_errno
18-
#define__set_errno(val) errno = (val)
19-
#endif
20-
21-
#undef __CONST
22-
#ifdef__GNUC__
23-
#define__CONST __const
24-
#else
25-
#define__CONST
19+
#define__set_errno(val) (errno = (val))
2620
#endif
2721

2822
typedefunsignedintBF_word;
@@ -31,7 +25,7 @@ unsigned char _crypt_itoa64[64 + 1] =
3125
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
3226

3327
char*_crypt_gensalt_traditional_rn(unsigned longcount,
34-
__CONSTchar*input,intsize,char*output,intoutput_size)
28+
constchar*input,intsize,char*output,intoutput_size)
3529
{
3630
if (size<2||output_size<2+1|| (count&&count!=25)) {
3731
if (output_size>0)output[0]='\0';
@@ -47,7 +41,7 @@ char *_crypt_gensalt_traditional_rn(unsigned long count,
4741
}
4842

4943
char*_crypt_gensalt_extended_rn(unsigned longcount,
50-
__CONSTchar*input,intsize,char*output,intoutput_size)
44+
constchar*input,intsize,char*output,intoutput_size)
5145
{
5246
unsigned longvalue;
5347

@@ -80,7 +74,7 @@ char *_crypt_gensalt_extended_rn(unsigned long count,
8074
}
8175

8276
char*_crypt_gensalt_md5_rn(unsigned longcount,
83-
__CONSTchar*input,intsize,char*output,intoutput_size)
77+
constchar*input,intsize,char*output,intoutput_size)
8478
{
8579
unsigned longvalue;
8680

@@ -121,7 +115,7 @@ char *_crypt_gensalt_md5_rn(unsigned long count,
121115
staticunsignedcharBF_itoa64[64+1]=
122116
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
123117

124-
staticvoidBF_encode(char*dst,__CONSTBF_word*src,intsize)
118+
staticvoidBF_encode(char*dst,constBF_word*src,intsize)
125119
{
126120
unsignedchar*sptr= (unsignedchar*)src;
127121
unsignedchar*end=sptr+size;
@@ -154,7 +148,7 @@ static void BF_encode(char *dst, __CONST BF_word *src, int size)
154148
}
155149

156150
char*_crypt_gensalt_blowfish_rn(unsigned longcount,
157-
__CONSTchar*input,intsize,char*output,intoutput_size)
151+
constchar*input,intsize,char*output,intoutput_size)
158152
{
159153
if (size<16||output_size<7+22+1||
160154
(count&& (count<4||count>31))) {

‎contrib/pgcrypto/internal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $Id: internal.c,v 1.4 2001/08/21 00:42:41 momjian Exp $
29+
* $Id: internal.c,v 1.5 2001/10/15 19:12:48 tgl Exp $
3030
*/
3131

3232

@@ -134,7 +134,7 @@ int_sha1_update(PX_MD * h, const uint8 * data, uint dlen)
134134
{
135135
SHA1_CTX*ctx= (SHA1_CTX*)h->p.ptr;
136136

137-
SHA1Update(ctx,(constchar*)data,dlen);
137+
SHA1Update(ctx,data,dlen);
138138
}
139139

140140
staticvoid

‎contrib/rserv/rserv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ _rserv_log_()
8787
if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
8888
newtuple=CurrentTriggerData->tg_newtuple;
8989

90+
#ifndefPG_FUNCTION_INFO_V1
9091
/*
9192
* Setting CurrentTriggerData to NULL prevents direct calls to trigger
9293
* functions in queries. Normally, trigger functions have to be called
9394
* by trigger manager code only.
9495
*/
9596
CurrentTriggerData=NULL;
97+
#endif
9698

9799
/* Connect to SPI manager */
98100
if ((ret=SPI_connect())<0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp