In C header tclPlatDecls.h where is TclPlatStubHooks defined? - c

I'm porting tcl/tk C headers to D and i've run into a type that doesn't seem to be defined anywhere. Inside the file tclPlatDecls.h there is the following definition:
typedef struct TclPlatStubs {
int magic;
struct TclPlatStubHooks *hooks;
#ifdef __WIN32__ /* WIN */
TCHAR * (*tcl_WinUtfToTChar) (CONST char *str, int len, Tcl_DString *dsPtr); /* 0 */
char * (*tcl_WinTCharToUtf) (CONST TCHAR *str, int len, Tcl_DString *dsPtr); /* 1 */
#endif /* WIN */
#ifdef MAC_OSX_TCL /* MACOSX */
int (*tcl_MacOSXOpenBundleResources) (Tcl_Interp *interp, CONST char *bundleName, int hasResourceFile, int maxPathLen, char *libraryPath); /* 0 */
int (*tcl_MacOSXOpenVersionedBundleResources) (Tcl_Interp *interp, CONST char *bundleName, CONST char *bundleVersion, int hasResourceFile, int maxPathLen, char *libraryPath); /* 1 */
#endif /* MACOSX */
} TclPlatStubs;
I can't find the definition of TclPlatStubHooks. Any idea where this is? I've grep'ed the entire code base and there is no definition anywhere. Even searching on the net yields no results.

For what it's worth, I'll confirm your grep is working, I found only that one reference to it as well, in versions 8.5.15 and 8.4.20.
What may be of interest is that in 8.6.1, the definition changes to void * as seen below.
typedef struct TclPlatStubs {
int magic;
void *hooks;
#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */
TCHAR * (*tcl_WinUtfToTChar) (const char *str, int len, Tcl_DString *dsPtr); /* 0 */
char * (*tcl_WinTCharToUtf) (const TCHAR *str, int len, Tcl_DString *dsPtr); /* 1 */
#endif /* WIN */
#ifdef MAC_OSX_TCL /* MACOSX */
int (*tcl_MacOSXOpenBundleResources) (Tcl_Interp *interp, const char *bundleName, int hasResourceFile, int maxPathLen, char *libraryPath); /* 0 */
int (*tcl_MacOSXOpenVersionedBundleResources) (Tcl_Interp *interp, const char *bundleName, const char *bundleVersion, int hasResourceFile, int maxPathLen, char *libraryPath); /* 1 */
#endif /* MACOSX */
} TclPlatStubs;
Maybe you could get away with treating it as a void *?

Related

gcc: conflicting types for 'malloc'; have 'char *()' - trying to build an ancient version of ls

I'm trying to build an ancient version of the ls command (written in pre-ANSI/ISO C). But I'm getting a lot of warnings, which for most of these I can fix, however I also get a few errors. This is one of them: error: conflicting types for ‘malloc’; have ‘char *()’
This is the affected part of the program:
static char sccsid[] = "#(#)ls.c 1.21";
/*
* list file or directory;
* define DOTSUP to suppress listing of files beginning with dot
*/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
#include <sys/stat.h>
#include <sys/dir.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef STANDALONE
#define TERMINFO
#endif
/* -DNOTERMINFO can be defined on the cc command line to prevent
* the use of terminfo. This should be done on systems not having
* the terminfo feature (pre 6.0 sytems ?).
* As a result, columnar listings assume 80 columns for output,
* unless told otherwise via the COLUMNS environment variable.
*/
#ifdef NOTERMINFO
#undef TERMINFO
#endif
#ifdef TERMINFO
#include <curses.h>
#include <term.h>
#endif
#define DOTSUP 1
#define ISARG 0100000 /* this bit equals 1 in lflags of structure lbuf
* if *namep is to be used;
*/
#define DIRECT 10 /* Number of direct blocks */
#ifdef u370
/* Number of pointers in an indirect block */
#define INDIR (BSIZE/sizeof(daddr_t))
/* Number of right shifts to divide by INDIR */
#define INSHFT 10
#else
/* Number of pointers in an indirect block */
#define INDIR 128
/* Number of right shifts to divide by INDIR */
#define INSHFT 7
#endif
struct lbuf {
union {
char lname[DIRSIZ]; /* used for filename in a directory */
char *namep; /* for name in ls-command; */
} ln;
char ltype; /* filetype */
unsigned short lnum; /* inode number of file */
short lflags; /* 0777 bits used as r,w,x permissions */
short lnl; /* number of links to file */
unsigned short luid;
unsigned short lgid;
long lsize; /* filesize or major/minor dev numbers */
long lmtime;
};
struct dchain {
char *dc_name; /* path name */
struct dchain *dc_next; /* next directory in the chain */
};
struct dchain *dfirst; /* start of the dir chain */
struct dchain *cdfirst; /* start of the durrent dir chain */
struct dchain *dtemp; /* temporary - used for linking */
char *curdir; /* the current directory */
int nfiles = 0; /* number of flist entries in current use */
int nargs = 0; /* number of flist entries used for arguments */
int maxfils = 0; /* number of flist/lbuf entries allocated */
int maxn = 0; /* number of flist entries with lbufs assigned */
int quantn = 1024; /* allocation growth quantum */
struct lbuf *nxtlbf; /* pointer to next lbuf to be assigned */
struct lbuf **flist; /* pointer to list of lbuf pointers */
struct lbuf *gstat();
FILE *pwdfu, *pwdfg, *dirf;
int aflg, bflg, cflg, dflg, fflg, gflg, iflg, lflg, mflg;
int nflg, oflg, pflg, qflg, sflg, tflg, uflg, xflg;
int Cflg, Fflg, Rflg;
int rflg = 1; /* initialized to 1 for special use in compar() */
int flags;
int err = 0; /* Contains return code */
char *dmark; /* Used if -p option active. Contains "/" or NULL. */
unsigned lastuid = -1, lastgid = -1;
int statreq; /* is > 0 if any of sflg, (n)lflg, tflg are on */
char *dotp = ".";
char *makename();
char tbufu[16], tbufg[16]; /* assumed 15 = max. length of user/group name */
char *ctime();
long nblock();
long tblocks; /* total number of blocks of files in a directory */
long year, now;
int num_cols = 80;
int colwidth;
int filewidth;
int fixedwidth;
int curcol;
int compar();
int new_line()
{
if (curcol) {
putc('\n',stdout);
curcol = 0;
}
}
int pprintf(char *s1, char *s2)
{
register char *s;
register int c;
register int cc;
int i;
for (s = s1, i = 0; i < 2; i++, s = s2)
while(c = *s++) {
if (c < ' ' || c >= 0177) {
if (qflg)
c = '?';
else if (bflg) {
curcol += 3;
putc ('\\', stdout);
cc = '0' + (c>>6 & 07);
putc (cc, stdout);
cc = '0' + (c>>3 & 07);
putc (cc, stdout);
c = '0' + (c & 07);
}
}
curcol++;
putc(c, stdout);
}
}
/*
* pdirectory: print the directory name, labelling it if title is
* nonzero, using lp as the place to start reading in the dir.
*/
int pdirectory (char *name, int title, int lp)
{
register struct dchain *dp;
register struct lbuf *ap;
register char *pname;
register int j;
filewidth = 0;
curdir = name;
if (title) {
putc('\n', stdout);
pprintf(name, ":");
new_line();
}
nfiles = lp;
readdir(name);
if (fflg==0)
qsort(&flist[lp],(unsigned)(nfiles - lp),sizeof(struct lbuf *),compar);
if (Rflg) for (j = nfiles - 1; j >= lp; j--) {
ap = flist[j];
if (ap->ltype == 'd' && strcmp(ap->ln.lname, ".") &&
strcmp(ap->ln.lname, "..")) {
dp = (struct dchain *)calloc(1,sizeof(struct dchain));
if (dp == NULL)
fprintf(stderr,"ls: out of memory\n");
pname = makename(curdir, ap->ln.lname);
dp->dc_name = (char *)calloc(1,strlen(pname)+1);
if (dp->dc_name == NULL) {
fprintf(stderr,"ls: out of memory\n");
free(dp);
}
else {
strcpy(dp->dc_name, pname);
dp -> dc_next = dfirst;
dfirst = dp;
}
}
}
if (lflg || sflg)
curcol += printf("total %ld", tblocks);
pem(&flist[lp],&flist[nfiles],lflg||sflg);
}
int main(int argc, char **argv)
{
extern char *optarg;
extern int optind;
int amino, opterr=0;
int c;
register struct lbuf *ep;
struct lbuf lb;
int i, width;
long time();
char *malloc();
void qsort(), exit();
malloc is declared in stdlib.h as :
void *malloc(size_t size);
You code wrongly re-declares it as:
char *malloc();
Remove the wrong re-declaration and review use of malloc() carefully.

How do I find declarations/definitions without an IDE?

I've been using the Eclipse IDE for a few years now. When programming in C I'm used to Ctrl+Click on a symbol and Eclipse takes me to the file and line of the symbol's declaration.
Without an IDE, how do I achieve this? I'm using gcc to compile a massive FOSS project with hundreds of header files. Looking though the C files, I see functions that I would like to know more about. Finding the header file that declares said function is a tedious and manual task. Not to mention manual interpretation of macros...
GCC compiles the project and knows what the declarations are and where. Is it possible to generate a human readable index of all symbol declarations along with their filename and position for a given compilation?
Sounds like you're looking for the -aux-info flag; it will write a list of all functions declared or defined in a translation unit (including those in header files) to a specified output file.
Here's a dumb piece of code I wrote for another SO question (don't remember what it was for):
#include <stdio.h>
int main( int argc, const char *argv[] )
{
const unsigned long long lim = 2000000;
unsigned long long nums2lim[lim];
printf( "%zu\n", sizeof nums2lim );
return 0;
}
Compiling it with
gcc -o test -std=c99 -pedantic -Wall -Werror -aux-info=test.aux test.c
yields this output in test.aux:
/* compiled from: . */
/* /usr/include/libio.h:413:NC */ extern int __underflow (_IO_FILE *);
/* /usr/include/libio.h:414:NC */ extern int __uflow (_IO_FILE *);
/* /usr/include/libio.h:415:NC */ extern int __overflow (_IO_FILE *, int);
/* /usr/include/libio.h:416:NC */ extern wint_t __wunderflow (_IO_FILE *);
/* /usr/include/libio.h:417:NC */ extern wint_t __wuflow (_IO_FILE *);
/* /usr/include/libio.h:418:NC */ extern wint_t __woverflow (_IO_FILE *, wint_t);
/* /usr/include/libio.h:451:NC */ extern int _IO_getc (_IO_FILE *);
/* /usr/include/libio.h:452:NC */ extern int _IO_putc (int, _IO_FILE *);
/* /usr/include/libio.h:453:NC */ extern int _IO_feof (_IO_FILE *);
/* /usr/include/libio.h:454:NC */ extern int _IO_ferror (_IO_FILE *);
/* /usr/include/libio.h:456:NC */ extern int _IO_peekc_locked (_IO_FILE *);
/* /usr/include/libio.h:462:NC */ extern void _IO_flockfile (_IO_FILE *);
/* /usr/include/libio.h:463:NC */ extern void _IO_funlockfile (_IO_FILE *);
/* /usr/include/libio.h:464:NC */ extern int _IO_ftrylockfile (_IO_FILE *);
/* /usr/include/libio.h:482:NC */ extern int _IO_vfscanf (_IO_FILE *, const char *, __va_list_tag *, int *);
/* /usr/include/libio.h:484:NC */ extern int _IO_vfprintf (_IO_FILE *, const char *, __va_list_tag *);
/* /usr/include/libio.h:485:NC */ extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
/* /usr/include/libio.h:486:NC */ extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
/* /usr/include/libio.h:488:NC */ extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
/* /usr/include/libio.h:489:NC */ extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
/* /usr/include/libio.h:491:NC */ extern void _IO_free_backup_area (_IO_FILE *);
/* /usr/include/stdio.h:154:NC */ extern int remove (const char *);
/* /usr/include/stdio.h:156:NC */ extern int rename (const char *, const char *);
/* /usr/include/stdio.h:171:NC */ extern FILE *tmpfile (void);
/* /usr/include/stdio.h:185:NC */ extern char *tmpnam (char *);
/* /usr/include/stdio.h:213:NC */ extern int fclose (FILE *);
/* /usr/include/stdio.h:218:NC */ extern int fflush (FILE *);
/* /usr/include/stdio.h:249:NC */ extern FILE *fopen (const char *, const char *);
/* /usr/include/stdio.h:256:NC */ extern FILE *freopen (const char *, const char *, FILE *);
/* /usr/include/stdio.h:309:NC */ extern void setbuf (FILE *, char *);
/* /usr/include/stdio.h:314:NC */ extern int setvbuf (FILE *, char *, int, size_t);
/* /usr/include/stdio.h:334:NC */ extern int fprintf (FILE *, const char *, ...);
/* /usr/include/stdio.h:339:NC */ extern int printf (const char *, ...);
/* /usr/include/stdio.h:342:NC */ extern int sprintf (char *, const char *, ...);
/* /usr/include/stdio.h:349:NC */ extern int vfprintf (FILE *, const char *, __va_list_tag *);
/* /usr/include/stdio.h:354:NC */ extern int vprintf (const char *, __va_list_tag *);
/* /usr/include/stdio.h:357:NC */ extern int vsprintf (char *, const char *, __va_list_tag *);
/* /usr/include/stdio.h:365:NC */ extern int snprintf (char *, size_t, const char *, ...);
/* /usr/include/stdio.h:369:NC */ extern int vsnprintf (char *, size_t, const char *, __va_list_tag *);
/* /usr/include/stdio.h:406:NC */ extern int fscanf (FILE *, const char *, ...);
/* /usr/include/stdio.h:411:NC */ extern int scanf (const char *, ...);
/* /usr/include/stdio.h:414:NC */ extern int sscanf (const char *, const char *, ...);
/* /usr/include/stdio.h:425:NC */ extern int vfscanf (FILE *, const char *, __va_list_tag *);
/* /usr/include/stdio.h:432:NC */ extern int vscanf (const char *, __va_list_tag *);
/* /usr/include/stdio.h:437:NC */ extern int vsscanf (const char *, const char *, __va_list_tag *);
/* /usr/include/stdio.h:447:NC */ extern int fgetc (FILE *);
/* /usr/include/stdio.h:448:NC */ extern int getc (FILE *);
/* /usr/include/stdio.h:454:NC */ extern int getchar (void);
/* /usr/include/stdio.h:489:NC */ extern int fputc (int, FILE *);
/* /usr/include/stdio.h:490:NC */ extern int putc (int, FILE *);
/* /usr/include/stdio.h:496:NC */ extern int putchar (int);
/* /usr/include/stdio.h:539:NC */ extern char *fgets (char *, int, FILE *);
/* /usr/include/stdio.h:546:NC */ extern char *gets (char *);
/* /usr/include/stdio.h:596:NC */ extern int fputs (const char *, FILE *);
/* /usr/include/stdio.h:602:NC */ extern int puts (const char *);
/* /usr/include/stdio.h:609:NC */ extern int ungetc (int, FILE *);
/* /usr/include/stdio.h:617:NC */ extern size_t fread (void *, size_t, size_t, FILE *);
/* /usr/include/stdio.h:623:NC */ extern size_t fwrite (const void *, size_t, size_t, FILE *);
/* /usr/include/stdio.h:656:NC */ extern int fseek (FILE *, long int, int);
/* /usr/include/stdio.h:661:NC */ extern long int ftell (FILE *);
/* /usr/include/stdio.h:666:NC */ extern void rewind (FILE *);
/* /usr/include/stdio.h:705:NC */ extern int fgetpos (FILE *, fpos_t *);
/* /usr/include/stdio.h:710:NC */ extern int fsetpos (FILE *, const fpos_t *);
/* /usr/include/stdio.h:733:NC */ extern void clearerr (FILE *);
/* /usr/include/stdio.h:735:NC */ extern int feof (FILE *);
/* /usr/include/stdio.h:737:NC */ extern int ferror (FILE *);
/* /usr/include/stdio.h:753:NC */ extern void perror (const char *);
/* test.c:4:NF */ extern int main (int argc, const char **argv); /* (argc, argv) int argc; const char **argv; */
This flag only works for C code, though - it won't give you anything for C++.
A light-weight, hackish approach would be to grep through the header files for the function name. Linux syntax would be something like:
find . -type f -name "*.h" | xargs grep [functionName]
It's what I use for my moderately-sized projects. I can't speak to how well it would scale.

Segmentation fault around MD5 code

While I am running this md5 code, it is taking maximum 64 characters length of input at run time. Whenever I am giving more than 64 characters, it is showing
Inconsistency detected by ld.so: dl-fini.c: 205: _dl_fini: Assertion ns != 0 || i == nloaded failed!
I need to hash nearly 10kb of input (only string). Do I need to change anything in the header file? Can anyone tell me solution please?
md5.h
#ifndef HEADER_MD5_H
#define HEADER_MD5_H
#include <openssl/e_os2.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef OPENSSL_NO_MD5
#error MD5 is disabled.
#endif
/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !
* ! MD5_LONG_LOG2 has to be defined along. !
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
#if defined(__LP64__)
#define MD5_LONG unsigned long
#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
#define MD5_LONG unsigned long
#define MD5_LONG_LOG2 3
/*
* _CRAY note. I could declare short, but I have no idea what impact
* does it have on performance on none-T3E machines. I could declare
* int, but at least on C90 sizeof(int) can be chosen at compile time.
* So I've chosen long...
* <appro#fy.chalmers.se>
*/
#else
#define MD5_LONG unsigned long
#endif
#define MD5_CBLOCK 64
#define MD5_LBLOCK (MD5_CBLOCK/2)
#define MD5_DIGEST_LENGTH 16
typedef struct MD5state_st
{
MD5_LONG A,B,C,D;
MD5_LONG Nl,Nh;
MD5_LONG data[MD5_LBLOCK];
unsigned int num;
} MD5_CTX;
#ifdef OPENSSL_FIPS
int private_MD5_Init(MD5_CTX *c);
#endif
int MD5_Init(MD5_CTX *c);
int MD5_Update(MD5_CTX *c, const void *data, size_t len);
int MD5_Final(unsigned char *md, MD5_CTX *c);
unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
void MD5_Transform(MD5_CTX *c, const unsigned char *b);
#ifdef __cplusplus
}
#endif
#endif
md5.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "md5.h"
char *pt(char *, int );
int main(int argc, char **argv)
{
char *in;
char *out;
printf("ENter the string\n");
scanf("%[^\n]s",in);
size_t len; //unsigned long len; size_t len;
len = printf("len is %d\n",strlen(in));
out = pt(in, len);
printf("MD5 is\t: %s\n", out);
free(out);
//return 0;
}
char *pt(char *str, int length)
{
int n;
MD5_CTX c;
unsigned char digest[16];
char *output = (char*)malloc(33);
MD5_Init(&c);
MD5_Update(&c, str, length);
MD5_Final(digest, &c);
for (n = 0; n < 16; ++n)
{
sprintf(&output[n*2], "%02x", (unsigned int)digest[n]);
}
return output;
}
Problem 1
For this statement:
scanf("%[^\n]s",in);
When I compile it using the -Wall flag, I get the warning:
warning: 'in' is used uninitialized in this function [-Wuninitialized]
scanf("%[^\n]s",in);
^
As you see, in is not pointing to any location in your memory, so you first need to allocate some memory either with an array or malloc():
char in[500]; //or a higher value
char *out;
printf("Enter the string\n");
scanf("%499[^\n]s", in);
printf("\nin = .%s.\n", in);
or
char *in;
char *out;
in = malloc(500); //or a higher value
printf("Enter the string\n");
scanf("%499[^\n]s", in);
printf("\nin = .%s.\n", in);
Possible problem 2
You are assigning the return from printf() to the variable len.
len = printf("len is %d\n",strlen(in));
Return value printf:
Upon successful return, it returns the number of characters printed (excluding the null byte used to end output to strings).
Assuming you want the variable len to contain the length of the string in and not the number of characters printed by printf("len is %d\n",strlen(in)), you might want to assign the return from strlen() first:
len = strlen(in);
printf("len is %d\n", len);

OpenSSL RSA_size with EVP_PKEY

I have a question regarding RSA_size.
Version that crash on WIN32 but works on linux platforms :
...
EVP_PKEY* pPublicKey = null;
unsigned int uKeySize = 0;
const unsigned char *pData;
pData = a_publicKey->Key.Data; /* Key.Data = unsigned char *p containing the Key in a string version */
pPublicKey = d2i_PublicKey(EVP_PKEY_RSA, null, &pData, a_publicKey->Key.Length);
if(pPublicKey != null)
{
uKeySize = RSA_size(pPublicKey->pkey.rsa); //Crash
}
...
Version that work on win32 (not tested on linux but I suppose it works as well):
...
EVP_PKEY* pPublicKey = null;
RSA* pRsaPublicKey = null;
unsigned int uKeySize = 0;
const unsigned char *pData;
pData = a_publicKey->Key.Data; /* Key.Data = unsigned char *p containing the Key in a string version */
pPublicKey = d2i_PublicKey(EVP_PKEY_RSA, null, &pData, a_publicKey->Key.Length);
if(pPublicKey != null)
{
pRsaPublicKey = EVP_PKEY_get1_RSA(pPublicKey);
EVP_PKEY_free(pPublicKey);
uKeySize = RSA_size(pRsaPublicKey);
}
...
I do not understand why the first version crash. But when I look into the pkey.rsa structure, values are not the same as in the RSA pointer in the 2nd version.
Any ideas ?
I looked into EVP_PKEY struct and it seems that WIN32 and linux version are different...
So I guess i am using a really old one for my WIN32.
WIN32 version :
struct evp_pkey_st
{
int type;
int save_type;
int references;
union {
char *ptr;
#ifndef OPENSSL_NO_RSA
struct rsa_st *rsa; /* RSA */
#endif
#ifndef OPENSSL_NO_DSA
struct dsa_st *dsa; /* DSA */
#endif
#ifndef OPENSSL_NO_DH
struct dh_st *dh; /* DH */
#endif
#ifndef OPENSSL_NO_EC
struct ec_key_st *ec; /* ECC */
#endif
} pkey;
int save_parameters;
STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
} /* EVP_PKEY */;
linux :
struct evp_pkey_st
{
int type;
int save_type;
int references;
const EVP_PKEY_ASN1_METHOD *ameth;
ENGINE *engine;
union {
char *ptr;
#ifndef OPENSSL_NO_RSA
struct rsa_st *rsa; /* RSA */
#endif
#ifndef OPENSSL_NO_DSA
struct dsa_st *dsa; /* DSA */
#endif
#ifndef OPENSSL_NO_DH
struct dh_st *dh; /* DH */
#endif
#ifndef OPENSSL_NO_EC
struct ec_key_st *ec; /* ECC */
#endif
} pkey;
int save_parameters;
STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
} /* EVP_PKEY */;

error: expected identifier or '(' before numeric constant

error when compiling kernel, this really gives me headache. couldnt figure out whats wrong. multi-line macro definition already escaped by newline.
actual error is
include/linux/mmc/sdio_func.h:169:2: error: expected identifier or '(' before ')' token
header file that trigger the error
/*
* include/linux/mmc/sdio_func.h
*
* Copyright 2007-2008 Pierre Ossman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*/
#ifndef MMC_SDIO_FUNC_H
#define MMC_SDIO_FUNC_H
#include <linux/device.h>
#include <linux/mod_devicetable.h>
#include <linux/mmc/pm.h>
struct mmc_card;
struct sdio_func;
typedef void (sdio_irq_handler_t)(struct sdio_func *);
/*
* Structure used to hold embedded SDIO device data from platform layer
*/
struct sdio_embedded_func {
uint8_t f_class;
uint32_t f_maxblksize;
};
/*
* SDIO function CIS tuple (unknown to the core)
*/
struct sdio_func_tuple {
struct sdio_func_tuple *next;
unsigned char code;
unsigned char size;
unsigned char data[0];
};
/*
* SDIO function devices
*/
struct sdio_func {
struct mmc_card *card; /* the card this device belongs to */
struct device dev; /* the device */
sdio_irq_handler_t *irq_handler; /* IRQ callback */
unsigned int num; /* function number */
unsigned char class; /* standard interface class */
unsigned short vendor; /* vendor id */
unsigned short device; /* device id */
unsigned max_blksize; /* maximum block size */
unsigned cur_blksize; /* current block size */
unsigned enable_timeout; /* max enable timeout in msec */
unsigned int state; /* function state */
#define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */
u8 tmpbuf[4]; /* DMA:able scratch buffer */
unsigned num_info; /* number of info strings */
const char **info; /* info strings */
struct sdio_func_tuple *tuples;
};
#define sdio_func_present(f) ((f)->state & SDIO_STATE_PRESENT)
#define sdio_func_set_present(f) ((f)->state |= SDIO_STATE_PRESENT)
#define sdio_func_id(f) (dev_name(&(f)->dev))
#define sdio_get_drvdata(f) dev_get_drvdata(&(f)->dev)
#define sdio_set_drvdata(f,d) dev_set_drvdata(&(f)->dev, d)
#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev)
/*
* SDIO function device driver
*/
struct sdio_driver {
char *name;
const struct sdio_device_id *id_table;
int (*probe)(struct sdio_func *, const struct sdio_device_id *);
void (*remove)(struct sdio_func *);
struct device_driver drv;
};
#define to_sdio_driver(d) container_of(d, struct sdio_driver, drv)
/**
* SDIO_DEVICE - macro used to describe a specific SDIO device
* #vend: the 16 bit manufacturer code
* #dev: the 16 bit function id
*
* This macro is used to create a struct sdio_device_id that matches a
* specific device. The class field will be set to SDIO_ANY_ID.
*/
#define SDIO_DEVICE(vend,dev) \
.class = SDIO_ANY_ID, \
.vendor = (vend), .device = (dev)
/**
* SDIO_DEVICE_CLASS - macro used to describe a specific SDIO device class
* #dev_class: the 8 bit standard interface code
*
* This macro is used to create a struct sdio_device_id that matches a
* specific standard SDIO function type. The vendor and device fields will
* be set to SDIO_ANY_ID.
*/
#define SDIO_DEVICE_CLASS(dev_class) \
.class = (dev_class), \
.vendor = SDIO_ANY_ID, .device = SDIO_ANY_ID
extern int sdio_register_driver(struct sdio_driver *);
extern void sdio_unregister_driver(struct sdio_driver *);
/*
* SDIO I/O operations
*/
extern void sdio_claim_host(struct sdio_func *func);
extern void sdio_release_host(struct sdio_func *func);
extern int sdio_enable_func(struct sdio_func *func);
extern int sdio_disable_func(struct sdio_func *func);
extern int sdio_set_block_size(struct sdio_func *func, unsigned blksz);
extern int sdio_claim_irq(struct sdio_func *func, sdio_irq_handler_t *handler);
extern int sdio_release_irq(struct sdio_func *func);
extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
extern u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret);
extern u8 sdio_readb_ext(struct sdio_func *func, unsigned int addr, int *err_ret,
unsigned in);
extern u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret);
extern u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret);
extern int sdio_memcpy_fromio(struct sdio_func *func, void *dst,
unsigned int addr, int count);
extern int sdio_readsb(struct sdio_func *func, void *dst,
unsigned int addr, int count);
extern void sdio_writeb(struct sdio_func *func, u8 b,
unsigned int addr, int *err_ret);
extern void sdio_writew(struct sdio_func *func, u16 b,
unsigned int addr, int *err_ret);
extern void sdio_writel(struct sdio_func *func, u32 b,
unsigned int addr, int *err_ret);
extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr,
void *src, int count);
extern int sdio_writesb(struct sdio_func *func, unsigned int addr,
void *src, int count);
extern unsigned char sdio_f0_readb(struct sdio_func *func,
unsigned int addr, int *err_ret);
extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b,
unsigned int addr, int *err_ret);
extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func);
extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags);
#endif
line 169 is the last line of code before the #endif, but seeing it i just cant figure out whats wrong with it.
mmc_pm_flag_t type is not known to the compiler. Did you include the correct headers? If yes, check the headers and see if you need to enable some macro.

Resources