Skip to content

Commit

Permalink
Use stack storage in isgenq.c
Browse files Browse the repository at this point in the history
Signed-off-by: Irek Fakhrutdinov <[email protected]>
  • Loading branch information
ifakhrutdinov committed Aug 21, 2024
1 parent 8dc8801 commit 1eb7103
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 159 deletions.
206 changes: 48 additions & 158 deletions c/isgenq.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
#include <metal/metal.h>
#include <metal/stddef.h>
#include <metal/stdint.h>
#include <metal/string.h>
#else
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#endif

#include "zowetypes.h"
#include "alloc.h"
#include "isgenq.h"


Expand All @@ -32,21 +29,7 @@ int isgenqTryExclusiveLock(const QName *qname,
ENQToken *token,
int *reasonCode) {

ALLOC_STRUCT31(
STRUCT31_NAME(mem31),
STRUCT31_FIELDS(
QName qname;
RName rname;
ENQToken token;
uint8_t scope;
char padding[7];
char parmList[200];
)
);

mem31->qname = *qname;
mem31->rname = *rname;
mem31->scope = scope;
char parmList[200];

int rc = 0, rsn = 0;
__asm(
Expand Down Expand Up @@ -78,23 +61,20 @@ int isgenqTryExclusiveLock(const QName *qname,
" DROP \n"
" POP USING \n"

: [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)
: [token]"=m"(*token), [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)

: [qname]"m"(mem31->qname.value),
[rname]"m"(mem31->rname.value),
[rname_len]"m"(mem31->rname.length),
[scope]"m"(mem31->scope), [token]"m"(mem31->token),
[parmlist]"m"(mem31->parmList)
: [qname]"m"(qname->value),
[rname]"m"(rname->value),
[rname_len]"m"(rname->length),
[scope]"m"(scope),
[parmlist]"m"(parmList)

: "r1", "r2", "r14"
: "r1", "r2", "r14"
);

if (reasonCode != NULL) {
*reasonCode = rsn;
}
*token = mem31->token;

FREE_STRUCT31(mem31);

return rc;
}
Expand All @@ -105,21 +85,7 @@ int isgenqGetExclusiveLock(const QName *qname,
ENQToken *token,
int *reasonCode) {

ALLOC_STRUCT31(
STRUCT31_NAME(mem31),
STRUCT31_FIELDS(
QName qname;
RName rname;
ENQToken token;
uint8_t scope;
char padding[7];
char parmList[200];
)
);

mem31->qname = *qname;
mem31->rname = *rname;
mem31->scope = scope;
char parmList[200];

int rc = 0, rsn = 0;
__asm(
Expand Down Expand Up @@ -151,23 +117,20 @@ int isgenqGetExclusiveLock(const QName *qname,
" DROP \n"
" POP USING \n"

: [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)
: [token]"=m"(*token), [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)

: [qname]"m"(mem31->qname.value),
[rname]"m"(mem31->rname.value),
[rname_len]"m"(mem31->rname.length),
[scope]"m"(mem31->scope), [token]"m"(mem31->token),
[parmlist]"m"(mem31->parmList)
: [qname]"m"(qname->value),
[rname]"m"(rname->value),
[rname_len]"m"(rname->length),
[scope]"m"(scope),
[parmlist]"m"(parmList)

: "r1", "r2", "r14"
);

if (reasonCode != NULL) {
*reasonCode = rsn;
}
*token = mem31->token;

FREE_STRUCT31(mem31);

return rc;
}
Expand All @@ -178,21 +141,7 @@ int isgenqTrySharedLock(const QName *qname,
ENQToken *token,
int *reasonCode) {

ALLOC_STRUCT31(
STRUCT31_NAME(mem31),
STRUCT31_FIELDS(
QName qname;
RName rname;
ENQToken token;
uint8_t scope;
char padding[7];
char parmList[200];
)
);

mem31->qname = *qname;
mem31->rname = *rname;
mem31->scope = scope;
char parmList[200];

int rc = 0, rsn = 0;
__asm(
Expand Down Expand Up @@ -224,23 +173,20 @@ int isgenqTrySharedLock(const QName *qname,
" DROP \n"
" POP USING \n"

: [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)
: [token]"=m"(*token), [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)

: [qname]"m"(mem31->qname.value),
[rname]"m"(mem31->rname.value),
[rname_len]"m"(mem31->rname.length),
[scope]"m"(mem31->scope), [token]"m"(mem31->token),
[parmlist]"m"(mem31->parmList)
: [qname]"m"(qname->value),
[rname]"m"(rname->value),
[rname_len]"m"(rname->length),
[scope]"m"(scope),
[parmlist]"m"(parmList)

: "r1", "r2", "r14"
);

if (reasonCode != NULL) {
*reasonCode = rsn;
}
*token = mem31->token;

FREE_STRUCT31(mem31);

return rc;
}
Expand All @@ -251,21 +197,7 @@ int isgenqGetSharedLock(const QName *qname,
ENQToken *token,
int *reasonCode) {

ALLOC_STRUCT31(
STRUCT31_NAME(mem31),
STRUCT31_FIELDS(
QName qname;
RName rname;
ENQToken token;
uint8_t scope;
char padding[7];
char parmList[200];
)
);

mem31->qname = *qname;
mem31->rname = *rname;
mem31->scope = scope;
char parmList[200];

int rc = 0, rsn = 0;
__asm(
Expand Down Expand Up @@ -297,23 +229,20 @@ int isgenqGetSharedLock(const QName *qname,
" DROP \n"
" POP USING \n"

: [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)
: [token]"=m"(*token), [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)

: [qname]"m"(mem31->qname.value),
[rname]"m"(mem31->rname.value),
[rname_len]"m"(mem31->rname.length),
[scope]"m"(mem31->scope), [token]"m"(mem31->token),
[parmlist]"m"(mem31->parmList)
: [qname]"m"(qname->value),
[rname]"m"(rname->value),
[rname_len]"m"(rname->length),
[scope]"m"(scope),
[parmlist]"m"(parmList)

: "r1", "r2", "r14"
);

if (reasonCode != NULL) {
*reasonCode = rsn;
}
*token = mem31->token;

FREE_STRUCT31(mem31);

return rc;
}
Expand All @@ -323,21 +252,8 @@ int isgenqTestLock(const QName *qname,
uint8_t scope,
int *reasonCode) {

ALLOC_STRUCT31(
STRUCT31_NAME(mem31),
STRUCT31_FIELDS(
QName qname;
RName rname;
ENQToken token;
uint8_t scope;
char padding[7];
char parmList[200];
)
);

mem31->qname = *qname;
mem31->rname = *rname;
mem31->scope = scope;
ENQToken token;
char parmList[200];

int rc = 0, rsn = 0;
__asm(
Expand Down Expand Up @@ -367,13 +283,13 @@ int isgenqTestLock(const QName *qname,
" DROP \n"
" POP USING \n"

: [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)
: [token]"=m"(token), [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)

: [qname]"m"(mem31->qname.value),
[rname]"m"(mem31->rname.value),
[rname_len]"m"(mem31->rname.length),
[scope]"m"(mem31->scope), [token]"m"(mem31->token),
[parmlist]"m"(mem31->parmList)
: [qname]"m"(qname->value),
[rname]"m"(rname->value),
[rname_len]"m"(rname->length),
[scope]"m"(scope),
[parmlist]"m"(parmList)

: "r1", "r2", "r14"
);
Expand All @@ -382,8 +298,6 @@ int isgenqTestLock(const QName *qname,
*reasonCode = rsn;
}

FREE_STRUCT31(mem31);

return rc;
}

Expand All @@ -401,21 +315,8 @@ int isgenqTestSharedLock(const QName *qname,
uint8_t scope,
int *reasonCode) {

ALLOC_STRUCT31(
STRUCT31_NAME(mem31),
STRUCT31_FIELDS(
QName qname;
RName rname;
ENQToken token;
uint8_t scope;
char padding[7];
char parmList[200];
)
);

mem31->qname = *qname;
mem31->rname = *rname;
mem31->scope = scope;
ENQToken token;
char parmList[200];

int rc = 0, rsn = 0;
__asm(
Expand Down Expand Up @@ -445,13 +346,13 @@ int isgenqTestSharedLock(const QName *qname,
" DROP \n"
" POP USING \n"

: [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)
: [token]"=m"(token), [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)

: [qname]"m"(mem31->qname.value),
[rname]"m"(mem31->rname.value),
[rname_len]"m"(mem31->rname.length),
[scope]"m"(mem31->scope), [token]"m"(mem31->token),
[parmlist]"m"(mem31->parmList)
: [qname]"m"(qname->value),
[rname]"m"(rname->value),
[rname_len]"m"(rname->length),
[scope]"m"(scope),
[parmlist]"m"(parmList)

: "r1", "r2", "r14"
);
Expand All @@ -460,22 +361,12 @@ int isgenqTestSharedLock(const QName *qname,
*reasonCode = rsn;
}

FREE_STRUCT31(mem31);

return rc;
}

int isgenqReleaseLock(ENQToken *token, int *reasonCode) {

ALLOC_STRUCT31(
STRUCT31_NAME(mem31),
STRUCT31_FIELDS(
ENQToken token;
char parmList[200];
)
);
int isgenqReleaseLock(const ENQToken *token, int *reasonCode) {

mem31->token = *token;
char parmList[200];

int rc = 0, rsn = 0;
__asm(
Expand All @@ -499,15 +390,14 @@ int isgenqReleaseLock(ENQToken *token, int *reasonCode) {

: [rc]"=NR:r15"(rc), [rsn]"=NR:r0"(rsn)

: [token]"m"(mem31->token), [parmlist]"m"(mem31->parmList)
: [token]"m"(*token), [parmlist]"m"(parmList)

: "r1", "r2", "r14"
);

if (reasonCode != NULL) {
*reasonCode = rsn;
}
*token = mem31->token;

return rc;
}
Expand Down
2 changes: 1 addition & 1 deletion h/isgenq.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int isgenqTestLock(const QName *qname,
* @param reasonCode Reason code from ISGENQ
* @return Return code from ISGENQ
*/
int isgenqReleaseLock(ENQToken *token, int *reasonCode);
int isgenqReleaseLock(const ENQToken *token, int *reasonCode);

#define IS_ISGENQ_LOCK_OBTAINED($isgenqRC, $isgenqRSN) \
($isgenqRC <= 4 && ((unsigned)$isgenqRSN & 0xFFFF) != 0x0404)
Expand Down

0 comments on commit 1eb7103

Please sign in to comment.